Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (NetBSD-2.0)
Apropos / Subsearch:
optional field

SETRUNQUEUE(9)           BSD Kernel Developer's Manual          SETRUNQUEUE(9)

     setrunqueue, remrunqueue, nextrunqueue -- manipulate system run queue

     #include <&lt;sys/proc.h>&gt;
     #include <&lt;sys/sched.h>&gt;

     setrunqueue(struct proc *p);

     remrunqueue(struct proc *p);

     struct proc *

     The setrunqueue(), remrunqueue(), and nextrunqueue() functions manipulate
     the system queue of runnable processes.  The system scheduler uses this
     queue to find the highest-priority process when a process switch occurs.
     These functions are generally machine-dependent implementations in order
     to permit efficient implementation of priority-based process selection.

     Currently, these functions are scheduler specific and correspond to the
     default ``time-sharing'' scheduler in NetBSD.  Their implementation is
     likely to change in the future to cater for different schedulers.

     The priority queue consists of an array sched_qs[NQS] of queue header
     structures each of which identifies a list of runnable processes of equal
     priority.  Lower indices in sched_qs indicate higher priority.  A single
     word sched_whichqs containing a bit mask identifying non-empty queues
     assists in selecting a process quickly.  The running process is on no
     queue, other processes are on a queue related to p->p_priority, divided
     by 4 actually to shrink the 0-127 range of priorities into the 32 avail-
     able queues.

     The setrunqueue() function places the given process on the system run
     queue.  It is an error to call setrunqueue() with a process that is not
     runnable or that is already on the system run queue or sleep queue.

     The remrunqueue() function removes the given process from the system run
     queue.  It is an error to call remrunqueue() with a process that is not
     on the system run queue.

     The nextrunqueue() function will make a choice amongst the processes
     which are ready to run from the priority run queue.  nextrunqueue() will
     remove the first process from the list on the queue with the highest pri-
     ority a return it.

     These functions must be called with the scheduler lock held (see
     SCHED_LOCK(9)) and at the splsched(9) interrupt protection level,

     SCHED_LOCK(9), scheduler(9), splsched(9)

BSD                           September 21, 2002                           BSD