[zion] Allow the sleep thread to be preempted.

We can't yield it when the next thread is unblocked for now because it
may still be holding a lock that the prempted thread is waiting on.
This commit is contained in:
Drew Galbraith 2023-06-19 21:47:37 -07:00
parent ec915338dc
commit 1cebe547c0
1 changed files with 8 additions and 1 deletions

View File

@ -42,7 +42,14 @@ void Scheduler::Preempt() {
if (current_thread_ == sleep_thread_) {
// Sleep should never be preempted. (We should yield it if another thread
// becomes scheduleable).
asm volatile("sti");
// FIXME: We should yield these threads instead of preempting them.
if (runnable_threads_.size() > 0) {
current_thread_ = runnable_threads_.PopFront();
sleep_thread_->SetState(Thread::RUNNABLE);
SwapToCurrent(*sleep_thread_);
} else {
asm volatile("sti");
}
return;
}