Having looked through various parts of the context switching code this week, I noticed that mi_switch() has a man page, and it's quite out of date.
tsleep() isn't the only sleep function, but I don't think there's much point listing them all. Additionally, yield() and preempt() also exist, but aren't documented. The 'renice after 10 minutes of cpu time' thing was removed in 2003 (r1.47 of kern_synch.c). It's more useful to mention the scheduler lock rather than a specific (wrong?) spl here, since mi_switch() does a SCHED_ASSERT_LOCKED(). ok? Alternatively, I'm not sure what the audience for this page is. It's mostly a list of reasons you don't need to call mi_switch() because either it happens to you automatically or it's used to implement part of some other function. Maybe we should just remove it and document the more useful kernel functions like yield()/preempt() better? diff --git mi_switch.9 mi_switch.9 index b04179fa79d..c53fb3ec11e 100644 --- mi_switch.9 +++ mi_switch.9 @@ -54,11 +54,12 @@ The three major uses of can be enumerated as follows: .Bl -enum -offset indent .It -From within -.Xr tsleep 9 -when the current process -voluntarily relinquishes the CPU to wait for some resource to become -available. +From within functions like +.Xr tsleep 9 , +when the current process sleeps to wait for some resource to become +available, or from within functions like +.Fn yield , +when it relinquishes the CPU to allow other processes to make progress. .It After handling a trap .Pq e.g., a system call or device interrupt @@ -85,8 +86,6 @@ Exceeding the soft limit results in a signal to be posted to the process, while exceeding the hard limit will cause a .Dv 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, .Fn mi_switch chooses the next process to run and hands over control to the machine @@ -105,8 +104,7 @@ Note that .Fn mi_switch and thus .Fn cpu_switchto -should be called at -.Xr splhigh 9 . +must be called while holding the scheduler lock. .Sh SEE ALSO .Xr spl 9 , .Xr tsleep 9 ,