It is simple and will be referenced by mi_switch(9).
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 49211 Build 46100: arc lint + arc unit
Event Timeline
share/man/man9/kern_yield.9 | ||
---|---|---|
72 | Maybe note that it's really mostly meant to be used by threads doing a lot of work in the kernel, which don't readily preempt each other (see preempt_thresh) and thus rely on each other to yield the CPU. The function effectively checks whether it's been a long time (relative to the scheduling quantum) since the thread yielded voluntarily and thus might be hogging a CPU. | |
89 | It's also a good idea to release locks before yielding, when possible. |
Two notes about priorities
- the kernel implements involuntary switching, so a thread hogging CPU should have special properties comparing to other threads that are starved.
- yielding does not guarantee that the yielding thread is removed from CPU, see note 1.
Explaining these two connected points in more details would be a useful service to the reader, IMO.
Also, the priority requested by kern_prio() is sticky until thread returns to usermode, which might be a surprise, AFAIR.
I think I understand these points, but to be clear you are mainly referring to interactivity score in ULE? As in, threads with a low voluntary sleep count could be categorized as non-interactive, and scheduled with lower priority than interactive timesharing threads. Therefore, the yielding thread may end up being the highest priority thread on the CPU's runqueues, and would be picked to continue running.
Also, the priority requested by kern_prio() is sticky until thread returns to usermode, which might be a surprise, AFAIR.
share/man/man9/kern_yield.9 | ||
---|---|---|
95 | I do not think this statement is true |
share/man/man9/kern_yield.9 | ||
---|---|---|
95 | Remarkably, with the default tuning of kern.sched.preempt_thresh, it is. sched_shouldpreempt() contains the logic. I did overlook one case, which is that interactive or better threads will preempt non-interactive (batch) threads running on remote CPUs. Nonetheless I will relax the language here slightly. |