mi_switch man page on OpenBSD

Man page or keyword search:  
man Server   11362 pages
apropos Keyword Search (all sections)
Output format
OpenBSD logo
[printable version]

MI_SWITCH(9)		     OpenBSD Kernel Manual		  MI_SWITCH(9)

NAME
     mi_switch, cpu_switchto - switch to another process context

SYNOPSIS
     #include <sys/param.h>
     #include <sys/proc.h>

     void
     mi_switch(void);

     void
     cpu_switchto(struct proc *old, struct proc *new);

DESCRIPTION
     The mi_switch() 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 follows:

	   1.	From within tsleep(9) when the current process voluntarily
		relinquishes the CPU to wait for some resource to become
		available.

	   2.	After handling a trap (e.g., a system call or device
		interrupt) when the kernel prepares a return to user-mode
		execution.  This case is typically handled by machine-
		dependent trap-handling code after detection of a change in
		the signal disposition of the current process, or when a
		higher priority process might be available to run.  The latter
		event is communicated by the machine-independent scheduling
		routines by calling the machine-dependent need_resched(void).

	   3.	In the signal handling code (see issignal(9)) if a signal is
		delivered that causes a process to stop.

     mi_switch() 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.  For a process which
     accumulated longer than 10 minutes of CPU time, its nice level is raised
     to 4.  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.

     cpu_switchto() will save the context of the old process and switch to the
     new one.  A special case is when the old process is NULL which means that
     the old process has exited and doesn't need to be saved.

     Note that mi_switch() and thus cpu_switchto() should be called at
     splhigh(9).

SEE ALSO
     spl(9), tsleep(9), wakeup(9)

OpenBSD 4.9			 June 26, 2008			   OpenBSD 4.9
[top]

List of man pages available for OpenBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net