ML 用的也算是抢先式调度,看看说明吧:
Voluntary Kernel Preemption (Desktop) (PREEMPT_VOLUNTARY)
This option reduces the latency of the kernel by adding more
"explicit preemption points" to the kernel code. These new
preemption points have been selected to reduce the maximum
latency of rescheduling, providing faster application reactions,
at the cost of slighly lower throughput.
This allows reaction to interactive events by allowing a
low priority process to voluntarily preempt itself even if it
is in kernel mode executing a system call. This allows
applications to run more 'smoothly' even when the system is
under load.
Select this if you are building a kernel for a desktop system.
LINUX内核有两种抢占模式。
User Preemption 和 Kernel Preemption
User Preemption 出现在:
1 When returning to user-space from a system call
2 When returning to user-space from an interrupt handler
这两个情况都会重置need_resched变量,从而导致重新调度。
这个好像2.4中就有了。
Kernel Preemption
In the 2.6 kernel,the Linux kernel became preemptive: It
is now possible to preempt a task at any point,so long as
the kernel is in a state in which it is safe to reschedule.
就是说,2.6之前的内核,程序调用进入内核(内核态)以后是无
法重新调度的(不可抢占),而2.6内核在以下情况可以重新调度
(可抢占):
1 When an interrupt handler exits, before returning to kernel
-space
2 When kernel code becomes preemptible again
3 If a task in the kernel explicitly calls schedule()
3 If a task in the kernel blocks(which results in a call to
schedule.