CSF(9) | Kernel Developer's Manual | CSF(9) |
CSF
—
#include <sys/sched.h>
void
sched_rqinit
(void);
void
sched_setup
(void);
void
sched_cpuattach
(struct
cpu_info *);
void
sched_tick
(struct
cpu_info *);
void
sched_schedclock
(lwp_t
*);
bool
sched_curcpu_runnable_p
(void);
lwp_t *
sched_nextlwp
(void);
void
sched_enqueue
(lwp_t
*, bool);
void
sched_dequeue
(lwp_t
*);
void
sched_nice
(struct
proc *, int);
void
sched_proc_fork
(struct
proc *, struct proc
*);
void
sched_proc_exit
(struct
proc *, struct proc
*);
void
sched_lwp_fork
(lwp_t
*);
void
sched_lwp_exit
(lwp_t
*);
void
sched_setrunnable
(lwp_t
*);
void
sched_print_runqueue
(void
(*pr)(const char *, ...));
void
sched_pstats_hook
(struct
proc *, int);
void
sched_pstats
(void
*arg);
pri_t
sched_kpri
(lwp_t
*);
void
resched_cpu
(lwp_t
*);
void
setrunnable
();
void
schedclock
(lwp_t
*);
void
sched_init
(void);
CSF
provides a modular and self-contained interface for
implementing different thread scheduling algorithms. The different schedulers
can be selected at compile-time. Currently, the schedulers available are
sched_4bsd(9), the
traditional 4.4BSD thread scheduler, and
sched_m2(9) which implements a
SVR4/Solaris like approach.
The interface is divided into two parts: A set of functions each scheduler needs to implement and common functions used by all schedulers.
sched_cpuattach
(struct cpu_info
*)sched_rqinit
(void)sched_setup
(void)sched_enqueue
(lwp_t *,
bool)sched_dequeue
(lwp_t *)sched_nextlwp
(void)sched_curcpu_runnable_p
(void)sched_print_runqueue
(void
(*pr)(const char *, ...))sched_tick
(struct cpu_info
*)sched_schedclock
(lwp_t *)schedclock
() in order to
handle priority adjustment.sched_nice
(struct proc *,
int)sched_proc_fork
(struct proc *,
struct proc *)fork
().sched_proc_exit
(struct proc *,
struct proc *)sched_lwp_fork
(lwp_t *)sched_lwp_exit
(lwp_t *)sched_setrunnable
(lwp_t
*)setrunnable
().sched_pstats_hook
(struct proc
*, int)sched_pstats
().sched_kpri
(lwp_t *)sched_pstats
(void *)resched_cpu
(lwp_t *)setrunnable
(lwp_t *)schedclock
(lwp_t *)statclock
().sched_init
(void)sched_pstats
() and call
sched_setup
() to initialize any other
scheduler-specific data.CSF
programming interface is defined within the file
sys/sys/sched.h.
Functions common to all scheduler implementations are in sys/kern/kern_synch.c.
The traditional 4.4BSD scheduler is implemented in sys/kern/sched_4bsd.c.
The M2 scheduler is implemented in sys/kern/sched_m2.c.
CSF
appeared in NetBSD 5.0.
CSF
was written by Daniel
Sieger ⟨dsieger@NetBSD.org⟩.
October 27, 2014 | NetBSD 9.0 |