/* * Wait on given wait queue. * Must be called with interrupts disabled! * Note that the function will return with interrupts * disabled. This is desirable, because it allows us to * atomically test a condition that can be affected by an interrupt * and wait for it to be satisfied (if necessary). * See the Wait_For_Key() function in keyboard.c * for an example. */ void Wait(struct Thread_Queue* waitQueue) { struct Kernel_Thread* current = g_currentThread; KASSERT(!Interrupts_Enabled()); /* Add the thread to the wait queue. */ Enqueue_Thread(waitQueue, current); /* Find another thread to run. */ Schedule(); }
/* * Add given thread to the run queue, so that it * may be scheduled. Must be called with interrupts disabled! */ void Make_Runnable(struct Kernel_Thread* kthread) { KASSERT(!Interrupts_Enabled()); { int currentQ = kthread->currentReadyQueue; KASSERT(currentQ >= 0 && currentQ < MAX_QUEUE_LEVEL); /* If the process is blocked, the priority level will increase by one level */ if(kthread->blocked == true && currentQ > 0) kthread->currentReadyQueue--; /* Prevent to idle process move out queue */ if(kthread->priority == PRIORITY_IDLE) kthread->currentReadyQueue = MAX_QUEUE_LEVEL - 1 ; kthread->blocked = false; Enqueue_Thread(&s_runQueue[kthread->currentReadyQueue], kthread); } }
/* * Add given thread to the run queue, so that it * may be scheduled. Must be called with interrupts disabled! */ void Make_Runnable(struct Kernel_Thread* kthread) { KASSERT(!Interrupts_Enabled()); Enqueue_Thread(&s_runQueue, kthread); }
/* * Hand given thread to the reaper for destruction. * Must be called with interrupts disabled! */ static void Reap_Thread(struct Kernel_Thread* kthread) { KASSERT(!Interrupts_Enabled()); Enqueue_Thread(&s_graveyardQueue, kthread); Wake_Up(&s_reaperWaitQueue); }