sched: add support for scheduling functions to be executed later

This commit is contained in:
2023-06-14 17:35:10 +01:00
parent cdb9fef36c
commit 4a1c6cae69
7 changed files with 217 additions and 1 deletions

View File

@@ -71,3 +71,21 @@ void wakeup_one(struct waitqueue *q)
spin_unlock_irqrestore(&q->wq_lock, flags);
}
void sleep_forever(void)
{
struct thread *thr = current_thread();
struct runqueue *rq = thr->tr_rq;
unsigned long flags;
rq_lock(rq, &flags);
rq_remove_thread(rq, thr);
thr->tr_state = THREAD_SLEEPING;
rq_unlock(rq, flags);
while (thr->tr_state == THREAD_SLEEPING) {
schedule(SCHED_NORMAL);
}
}