[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:
Drew Galbraith 2023-12-07 00:19:17 -08:00
parent 66e94ac41b
commit 8adde27d9b
9 changed files with 48 additions and 5 deletions

View file

@ -23,18 +23,23 @@ class Scheduler {
void Preempt();
void Yield();
void Sleep(uint64_t millis);
private:
bool enabled_ = false;
glcr::RefPtr<Thread> current_thread_;
glcr::IntrusiveList<Thread> runnable_threads_;
glcr::IntrusiveList<Thread> sleeping_threads_;
glcr::RefPtr<Thread> sleep_thread_;
Scheduler();
void SwapToCurrent(Thread& prev);
void ClearDeadThreadsFromFront();
void DecrementSleepingThreads();
};
extern Scheduler* gScheduler;