Fix scheduler with sleeping task
This commit is contained in:
parent
b1e6bc1aab
commit
319f197fcd
@ -77,10 +77,13 @@ free_mem:
|
||||
|
||||
void kthreadDelete(struct kthread *thread)
|
||||
{
|
||||
uint32_t flags;
|
||||
disable_IRQs(flags);
|
||||
list_delete(currentThread, thread);
|
||||
|
||||
free((void *)thread->stackAddr);
|
||||
free((void *)thread);
|
||||
restore_IRQs(flags);
|
||||
}
|
||||
|
||||
struct kthread *kthreadSelectNext()
|
||||
@ -93,8 +96,7 @@ struct kthread *kthreadSelectNext()
|
||||
return nextThread;
|
||||
}
|
||||
}
|
||||
assert("Cannot find next thread\n");
|
||||
return nextThread;
|
||||
return currentThread;
|
||||
}
|
||||
|
||||
struct cpu_state *kthreadSwitch(struct cpu_state *prevCpu)
|
||||
@ -140,7 +142,9 @@ int kthreadYield()
|
||||
restore_IRQs(flags);
|
||||
return 0;
|
||||
}
|
||||
current->state = READY;
|
||||
assert(current->state == RUNNING);
|
||||
assert(next->state == READY);
|
||||
current->state = READY;
|
||||
currentThread = next;
|
||||
currentThread->state = RUNNING;
|
||||
cpu_context_switch(¤t->cpuState, next->cpuState);
|
||||
@ -152,10 +156,11 @@ int kthreadMsleep(unsigned long msec)
|
||||
{
|
||||
uint32_t flags;
|
||||
disable_IRQs(flags);
|
||||
struct kthread *next = kthreadSelectNext();
|
||||
struct kthread *current = currentThread;
|
||||
assert(current->state == RUNNING);
|
||||
current->state = SLEEPING;
|
||||
struct kthread *next = kthreadSelectNext();
|
||||
assert(next != current);
|
||||
current->state = SLEEPING;
|
||||
current->jiffiesSleeping = msecs_to_jiffies(msec);
|
||||
assert(next->state == READY);
|
||||
currentThread = next;
|
||||
|
@ -28,7 +28,7 @@ void idleThread(void *arg)
|
||||
(void)arg;
|
||||
while (1) {
|
||||
printIntDetails((jiffies / HZ), GREEN, BLACK, 0, VGA_HEIGHT - 1);
|
||||
//kthreadYield();
|
||||
kthreadYield();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user