Pre-empting

From Helpful
Jump to navigation Jump to search
This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

As a wider concept, pre-empting often 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 computer programming, 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 typically do (though note that interrupt functions are still often written in a "minimal code to move the data, so that a regular kernel process actually process it", which is a fairly cooperative atitude).

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 potentially allows 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