Pre-empting

From Helpful
Jump to: navigation, search
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, or tell me)

As a wider concept, pre-empting means an action attempting to stall or prevent an anticipated event.

For example

pre-empt a regular broadcast schedule to send special real-time news
emergency vehicles can pre-empt traffic signals
hold a press conference to pre-empt likely criticism
there are also a bunch of specific legal and financial examples [1]


In computers, pre-empting typically refers to pre-emptive multitasking, the ability to context-switch away from a running task without that task's cooperation.

...which is contrasted with cooperative multitasking/scheduling[2], where only a task itself can return control, when it wants to.


Having a scheduler that can pre-empt user tasks is typical of general-purpose OSes, so when used today, it may refer more specifically to kernel pre-emption than to general pre-emption.

Kernel-pre-emption refers to ensuring most/all kernel-mode code is also pre-emptible.

Say, interrupt functions may not be - because of what they are and do (though note that interrupt functions are often written in a "move the data out, so that a regular kernel process actually process it").

Drivers are often not pre-emptible, for similar reasons.

Syscalls are a more interesting case. Syscalls were historically not pre-emptible, but it is useful to allow this for syscalls that don't mind, because it words towards better parallelism within the kernel, and better guarantees for real-time OS time constraints. (...though it does imply serialized access, and thereby more locking, and thereby more considerations for things like deadlocks)

It also occasionally helps stability (as e.g. bugs in a driver could make a kernel wait forever).


https://en.wikipedia.org/wiki/Preemption_(computing)

https://en.wikipedia.org/wiki/Kernel_preemption