[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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
|
|||
void SetState(State state) { state_ = state; }
|
||||
void Exit();
|
||||
|
||||
void Wait();
|
||||
|
||||
private:
|
||||
friend class glcr::MakeRefCountedFriend<Thread>;
|
||||
Thread(Process& proc, uint64_t tid);
|
||||
|
|
@ -68,4 +70,6 @@ class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
|
|||
// Stack pointer to take when returning from userspace.
|
||||
// I don't think me mind clobbering the stack here.
|
||||
uint64_t rsp0_start_;
|
||||
|
||||
glcr::IntrusiveList<Thread> blocked_threads_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue