[Zion] Add a thread sleep call.
For now this can only sleep in increments of the scheduler quantum (currently 50ms). It also uses a somewhat ineffecient way of tracking the sleeping threads - it will scale linearly with the number of sleeping threads.
This commit is contained in:
parent
66e94ac41b
commit
8adde27d9b
9 changed files with 48 additions and 5 deletions
|
|
@ -29,6 +29,7 @@ class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
|
|||
RUNNING,
|
||||
RUNNABLE,
|
||||
BLOCKED,
|
||||
SLEEPING,
|
||||
CLEANUP,
|
||||
FINISHED,
|
||||
};
|
||||
|
|
@ -69,6 +70,9 @@ class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
|
|||
|
||||
void Wait();
|
||||
|
||||
void SetSleepTicks(uint64_t sleep_ticks) { sleep_ticks_ = sleep_ticks; }
|
||||
bool DecrementSleepTicks() { return --sleep_ticks_ == 0; }
|
||||
|
||||
private:
|
||||
friend class glcr::MakeRefCountedFriend<Thread>;
|
||||
Thread(Process& proc, uint64_t tid);
|
||||
|
|
@ -79,6 +83,7 @@ class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
|
|||
State state_ = CREATED;
|
||||
bool is_kernel_ = false;
|
||||
uint64_t user_stack_base_;
|
||||
uint64_t sleep_ticks_;
|
||||
|
||||
// Startup Context for the thread.
|
||||
uint64_t rip_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue