Non-preemptive execution is in most cases a more efficient way to carry out computation:
-
Context switching between threads is a relatively expensive operation. In a non-preemptive environment it occurs only when a thread cannot proceed (has to be blocked) or yields control (under program control). Thus, the management of switching contexts is optimal (assuming that application can control it optimally).
-
Unnecessary or too frequent switches not only waste CPU time but also disrupt caches and can produce page faults.
-
Handling asynchronous signals (mandatory for the preemptive mode) spoils cache localities and on some processors can generate a lot of extra operations.
|