sched: enforce ref-counting on current task/thread pointers
This commit is contained in:
+12
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user