SCHED(9)                                                 SCHED(9)

          anyhigher, anyready, hzsched, procpriority, procrestore,
          procsave, scheddump, schedinit, sched, yield – scheduler

          int   anyhigher(void)
          int   anyready(void)
          void  hzsched(void)
          void  procpriority(Proc *p, int priority, int fixed)
          void  procrestore(Proc *p)
          void  procsave(Proc *p)
          void  procwired(Proc *p, int machno)
          void  scheddump(void)
          void  schedinit(void)
          void  sched(void)
          void  yield(void)

          enum {
                Npriq             = 20,   /* scheduler priority levels */
                PriNormal = 10,   /* base for normal processes */
                PriKproc  = 13,   /* base for kernel processes */
                PriRoot   = 13,   /* base for root processes */

          These functions define the priority process scheduler's
          interface.  Processes are scheduled strictly by priority,
          and processor affinity.  When possible, processes with no
          affinity will be rescheduled on the same processor.  Within
          a priority, scheduling is round–robin.  Long–running
          processes of the same priority are preempted and
          rescheduled.  But cpu use (or lack thereof) may adjust the
          priority up or down, unless it has been explicitly fixed.
          Kernel processes are started with PriKproc while user pro-
          cesses start with PriNormal.

          Anyhigher returns true if any higher priority processes are
          runnable, while anyready returns true if any processes are
          runnable at all.  Yield gives up the processor and pretends
          to consume ½ clock tick, while sched invokes the scheduler,
          potentially recursively.  Sched may be called outside pro-
          cess context.  Either may return immediately.  Schedinit
          initializes scheduling on the running processor.

          Procpriority sets a process' priority directly.
          Fixed–priority processes are not reprioritized based on cpu
          use.  Procwired makes a process runnable only on a single

     Page 1                       Plan 9             (printed 4/22/24)

     SCHED(9)                                                 SCHED(9)

          Hzsched is called by the clock routine on every tick to col-
          lect statistics.  Periodically (typically once a second)
          hzsched reprioritizes based on cpu use.

          Procsave and procrestore are architecture–dependent routines
          used by the scheduler to save and restore processes.
          Scheddump prints scheduler statistics.

9          Procsave and procrestore can be found at

          edf(9), sleep(9)


     Page 2                       Plan 9             (printed 4/22/24)