Improved checks for WakeUpThreads

This commit is contained in:
Alex 2022-12-24 07:57:35 +02:00
parent 0ac4fa3e14
commit f07c10a2ee
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -359,15 +359,8 @@ namespace Tasking
continue; continue;
// Check process status. // Check process status.
switch (pcb->Status) if (pcb->Status == TaskStatus::Terminated)
{
case TaskStatus::Ready:
schedbg("Ready process (%s)%d", pcb->Name, pcb->ID);
break;
default:
schedbg("Process \"%s\"(%d) status %d", pcb->Name, pcb->ID, pcb->Status);
continue; continue;
}
// Loop through all the threads. // Loop through all the threads.
foreach (TCB *tcb in pcb->Threads) foreach (TCB *tcb in pcb->Threads)
@ -376,7 +369,7 @@ namespace Tasking
continue; continue;
// Check if the thread is sleeping. // Check if the thread is sleeping.
if (tcb->Status != TaskStatus::Sleeping) if (tcb->Status != TaskStatus::Sleeping || pcb->Status == TaskStatus::Terminated)
continue; continue;
// Check if the thread is ready to wake up. // Check if the thread is ready to wake up.
@ -451,7 +444,7 @@ namespace Tasking
CurrentCPU->CurrentThread->Status = TaskStatus::Ready; CurrentCPU->CurrentThread->Status = TaskStatus::Ready;
// Loop through all threads and find which one is ready. // Loop through all threads and find which one is ready.
WakeUpThreads(CurrentCPU); this->WakeUpThreads(CurrentCPU);
// Get next available thread from the list. // Get next available thread from the list.
if (this->GetNextAvailableThread(CurrentCPU)) if (this->GetNextAvailableThread(CurrentCPU))