sched: enforce ref-counting on current task/thread pointers

This commit is contained in:
2026-04-01 18:17:05 +01:00
parent 15c2207ab9
commit 512356ac2d
28 changed files with 364 additions and 103 deletions
+12 -2
View File
@@ -110,7 +110,7 @@ void wakeup_one(struct waitqueue *q)
void sleep_forever(void)
{
struct thread *thr = current_thread();
struct thread *thr = get_current_thread();
struct runqueue *rq = thr->tr_rq;
unsigned long flags;
@@ -121,7 +121,17 @@ void sleep_forever(void)
rq_unlock(rq, flags);
while (thr->tr_state == THREAD_SLEEPING) {
put_current_thread(thr);
while (1) {
thr = get_current_thread();
bool sleep = (thr->tr_state == THREAD_SLEEPING);
put_current_thread(thr);
if (!sleep) {
break;
}
schedule(SCHED_NORMAL);
}
}