[zion] Add a thread wait syscall

This commit is contained in:
Drew Galbraith 2023-06-22 02:17:50 -07:00
parent f0e8ce14a4
commit 36d82370c1
9 changed files with 45 additions and 8 deletions

View file

@ -69,5 +69,18 @@ void Thread::Exit() {
#endif
state_ = FINISHED;
process_.CheckState();
while (!blocked_threads_.size() == 0) {
auto thread = blocked_threads_.PopFront();
thread->SetState(Thread::RUNNABLE);
gScheduler->Enqueue(thread);
}
gScheduler->Yield();
}
void Thread::Wait() {
// FIXME: We need synchronization code here.
auto thread = gScheduler->CurrentThread();
thread->SetState(Thread::BLOCKED);
blocked_threads_.PushBack(thread);
gScheduler->Yield();
}