开发者

Kernel is non-preemptive.....How?

A proce开发者_如何学Pythonss which is executing in kernel mode can not be preempted.

How is it possible?

Consider the case that a process is executing in kernel mode and taking a lot of time. Due to this the rest of processes will remain in ready queue.

For example how would the process respond to timer interrupt (if it is executing in kernel mode)? Or how would it respond to high temperature cut off interrupt.

Please if somebody could clear my doubts


First things first, your assumptions are incorrect: the Linux kernel does provide limited kernel-mode preemption, if the config options CONFIG_PREEMPT_VOLUNTARY or CONFIG_PREEMPT are set.

With preemption turned on, tasks won't be preempted if they are holding locks; the kernel developers pay very close attention to how long processes hold locks, and try to reduce the amount of time that locks are held. (In part for preempt, in part because the longer locks are held, the less concurrent the system may be, if several processors are contending for the same lock. If the locks are held for short times, there is less contention and potentially higher throughput.)

Furthermore, the kernel developers try to limit the length of time a process may spend in kernel mode. After all, time spent in the kernel is time that isn't spent in the application, doing whatever it is the application does.

If the standard Linux kernel cannot provide you with good enough hard realtime performance handling interrupts, you can of course use a system such as RTLinux, for which commercial support is available.


Generally, interrupts are able to do just what their name implies, interrupt whatever is running at the time, be it an userspace process or a system call running in the kernel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜