MI_SWITCH(9) | Kernel Developer's Manual | MI_SWITCH(9) |
mi_switch() records the amount of time the current LWP has been running in the LWP structure and checks this value against the CPU time limits allocated to the LWP (see getrlimit(2)). Exceeding the soft limit results in a SIGXCPU signal to be posted to the LWP, while exceeding the hard limit will cause a SIGKILL.
Unless l->l_switchto is not NULL, mi_switch() will call sched_nextlwp() to select a new LWP from the scheduler's runqueue structures. If no runnable LWP is found, the idle LWP is used. If the new LWP is not equal to the current one, mi_switch() will hand over control to the machine-dependent function cpu_switchto(9) to switch to the new LWP.
mi_switch() has to be called with the LWP lock held (through calling lwp_lock() first) and at the splsched(9) interrupt protection level. It returns with the LWP lock released.
July 21, 2007 | NetBSD 6.1 |