I read the book "understanding the Linux kernel". I cannot understand a sentence,that is ,the local CPU must have local interrupts enabled, otherwise kernel preemption is not performed. What is the meaning of this sentence?

  • Don't have that book, I would assume its saying that preempt is done when the CPU receives an interrupt—so with them disabled, it won't work. You could help someone with the book to give you a non-guess answer with some more details (e.g., some context from the book and also section or page number where that sentence occurs). – derobert Jun 14 '16 at 17:16
  • If you want a deeper guess, it implies that pre-emption switching from one process to another requires a timer to work, which requires an interrupt to run. – infixed Jun 14 '16 at 17:34

If local (context implies "on This CPU") interrupts are forbidden, the (local) CPU will never see an interrupt to trigger possible kernel pre-emption.

  • but in function preempt_enable() which includes "if (!current_thread_info->preempt_count && !irqs_disabled()) { current_thread_info->preempt_count = PREEMPT_ACTIVE; schedule(); current_thread_info->preempt_count = 0; }". Why does the if statement chech whether the local interrupt is enabled by !irqs_disabled() – 80247617 aaa Jun 14 '16 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.