void wakeup(void)
{
/* Awaken all processes that have no more time to sleep */
while (nonempty(sleepq) && (firstkey(sleepq) <= 0)) {
ready(dequeue(sleepq), RESCHED_NO);
}
if ( (slnonempty = nonempty(sleepq)) == TRUE ) {
sltop = &queuetab[firstkey(sleepq)].qkey;
}
resched();
return;
}
The bug is on the line which gets the new value of sltop, we should be dereferencing the firstid in the sleep queue and not the firstkey.
void wakeup(void)
{
/* Awaken all processes that have no more time to sleep */
while (nonempty(sleepq) && (firstkey(sleepq) <= 0)) {
ready(dequeue(sleepq), RESCHED_NO);
}
if ( (slnonempty = nonempty(sleepq)) == TRUE ) {
sltop = &queuetab[firstid(sleepq)].qkey;
}
resched();
return;
}