Main index | Section 9 | Options |
#include <sys/param.h>
#include <sys/proc.h>extern struct rq itqueues[];
procrunnable() returns zero if there are no runnable processes other than the idle process. If there is at least one runnable process other than the idle process, it will return a non-zero value. Note that the sched_lock mutex does not need to be held when this function is called. There is a small race window where one CPU may place a process on the run queue when there are currently no other runnable processes while another CPU is calling this function. In that case the second CPU will simply travel through the idle loop one additional time before noticing that there is a runnable process. This works because idle CPUs are not halted in SMP systems. If idle CPUs are halted in SMP systems, then this race condition might have more serious repercussions in the losing case, and procrunnable() may have to require that the sched_lock mutex be acquired.
choosethread() returns the highest priority runnable thread. If there are no runnable threads, then the idle thread is returned. This function is called by cpu_switch() and cpu_throw() to determine which thread to switch to. choosethread() must be called with the sched_lock mutex held.
setrunqueue() adds the thread td to the tail of the appropriate queue in the proper priority queue. The thread must be runnable, i.e.amp; p_stat must be set to SRUN. This function must be called with the sched_lock mutex held.
remrunqueue() removes thread td from its run queue. If td is not on a run queue, then the kernel will panic(9). This function must be called with the sched_lock mutex held.
RUNQUEUE (9) | August 15, 2010 |
Main index | Section 9 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | Modern Unix impedes progress in computer science, wastes billions of dollars, and destroys the common sense of many who seriously use it. | ” |
— The Unix Haters' handbook |