[zion] Add a thread wait syscall
This commit is contained in:
parent
f0e8ce14a4
commit
36d82370c1
9 changed files with 45 additions and 8 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue