|MI_SWITCH(9)||Kernel Developer's Manual||MI_SWITCH(9)|
cpu_switchto — switch to
another process context
proc *old, struct proc
function implements the machine-independent prelude to a process context
switch. It is called from only a few distinguished places in the kernel code
as a result of the principle of non-preemptable kernel mode execution. The
three major uses of
mi_switch() can be enumerated as
yield(), when it relinquishes the CPU to allow other processes to make progress.
records the amount of time the current process has been running in the
process structure and checks this value against the CPU time limits
allocated to the process (see
getrlimit(2)). Exceeding the soft
limit results in a
SIGXCPU signal to be posted to
the process, while exceeding the hard limit will cause a
SIGKILL. After these administrative tasks are done,
mi_switch() chooses the next process to run and
hands over control to the machine dependent routine
cpu_switchto(), which will perform the actual
process context switch.
will save the context of the old process and switch to the new one. A
special case is when the old process is
means that the old process has exited and doesn't need to be saved.
cpu_switchto() must be called while holding
the scheduler lock.
|September 5, 2017||OpenBSD-current|