Kernel: Refactor synchronization to better match RE

This commit is contained in:
Fernando Sahmkow 2020-02-11 17:36:39 -04:00 committed by FernandoS27
parent c5aefe42aa
commit d23d504d77
23 changed files with 212 additions and 80 deletions

View file

@ -31,6 +31,10 @@ bool Thread::ShouldWait(const Thread* thread) const {
return status != ThreadStatus::Dead;
}
bool Thread::IsSignaled() const {
return status == ThreadStatus::Dead;
}
void Thread::Acquire(Thread* thread) {
ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
}
@ -45,7 +49,7 @@ void Thread::Stop() {
kernel.ThreadWakeupCallbackHandleTable().Close(callback_handle);
callback_handle = 0;
SetStatus(ThreadStatus::Dead);
WakeupAllWaitingThreads();
Signal();
// Clean up any dangling references in objects that this thread was waiting for
for (auto& wait_object : wait_objects) {