Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on.

This commit is contained in:
Subv 2017-01-04 10:53:01 -05:00
parent cef5f45de2
commit fd95b6ee26
4 changed files with 22 additions and 21 deletions

View file

@ -55,10 +55,16 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
if (ShouldWait(thread.get()))
continue;
bool ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(),
// A thread is ready to run if it's either in THREADSTATUS_WAIT_SYNCH_ANY or
// in THREADSTATUS_WAIT_SYNCH_ALL and the rest of the objects it is waiting on are ready.
bool ready_to_run = true;
if (thread->status == THREADSTATUS_WAIT_SYNCH_ALL) {
ready_to_run = std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(),
[&thread](const SharedPtr<WaitObject>& object) {
return object->ShouldWait(thread.get());
});
}
if (ready_to_run) {
candidate = thread.get();
candidate_priority = thread->current_priority;