new man page for the kernel process scheduler Reference: /n/atom/patch/applied/schedman Date: Sun Jun 8 13:04:01 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/man/9/sched Thu Jan 1 00:00:00 1970 +++ /sys/man/9/sched Sun Jun 8 13:03:59 2014 @@ -0,0 +1,109 @@ +.TH SCHED 9 +.SH NAME +anyhigher, anyready, hzsched, procpriority, procrestore, procsaved, procsave, scheddump, schedinit, schedstats, sched, yield \- scheduler interactions +.SH SYNOPSIS +.ta \w'\fLvoid 'u +.B +int anyhigher(void) +.PP +.B +int anyready(void) +.PP +.B +void hzsched(void); +.PP +.B +void procpriority(Proc *p, int priority, int fixed) +.PP +.B +void procrestore(Proc *p) +.PP +.B +int procsaved(Proc *p) +.PP +.B +void procsave(Proc *p) +.PP +.B +void procwired(Proc *p, int machno) +.PP +.B +void scheddump(void) +.PP +.B +void schedinit(void) +.PP +.B +char* schedstats(char *s, char *e) +.PP +.B +void sched(void) +.PP +.B +void yield(void) +.PP +.EX +Npriq = 20, /* scheduler priority levels */ +PriNormal = 10, /* base for normal processes */ +PriKproc = 13, /* base for kernel processes */ +PriRoot = 13, /* base for root processes */ +.EE +.SH DESCRIPTION +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 +.B PriKproc +while user processes start with +.BR PriNormal . +.PP +.I Anyhigher +returns true if any higher priority processes are runnable, while +.I anyready +returns true if any processes are runnable at all. +.I Yield +gives up the processor and pretends to consume ½ clock tick, +while +.I sched +invokes the scheduler, potentially recursively. +.I Sched +may be called outside process context. Either may return +immediately. +.I Schedinit +initializes scheduling on the running processor. +.PP +.I Procpriority +sets a process' priority directly. Fixed-priority processes are not +reprioritized based on cpu use. +.I Procwired +makes a process runnable only on a single processor. +.PP +.I Hzsched +is called by the clock routine on every tick to collect statistics. +Periodically + (typically once a second) +.I hzsched +reprioritizes based on cpu use. +.PP +.I Procsave +and +.I procrestore +are architecture-dependent routines used by the scheduler to save +and restore processes. +.I Procsaved +reliably determines if a process is not being run. +.I Scheddump +and +.I schedstats +print or return scheduler statistics. +.SH SOURCE +.B /sys/src/9/port/proc.c +.SH DIAGNOSTICS +.SH SEE ALSO +.IR edf (9), +.IR sleep (9)