Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an interrupt handler be preempted?

I know that linux does nested interrupts where one interrupt can "preempt" another interrupt, but what about with other tasks.

I am just trying to understand how linux handles interrupts. Can they be preempted by some other user task/kernel task.

like image 411
user623879 Avatar asked Dec 10 '22 08:12

user623879


2 Answers

Reading Why kernel code/thread executing in interrupt context cannot sleep? which links to Robert Loves article, I read this :

some interrupt handlers (known in Linux as fast interrupt handlers) run with all interrupts on the local processor disabled. This is done to ensure that the interrupt handler runs without interruption, as quickly as possible. More so, all interrupt handlers run with their current interrupt line disabled on all processors. This ensures that two interrupt handlers for the same interrupt line do not run concurrently. It also prevents device driver writers from having to handle recursive interrupts, which complicate programming.

So AFIK all IRQ's are disabled while within the interrupt handler, therefore it cannot be interrupted!?

like image 60
Ian Vaughan Avatar answered Jan 02 '23 09:01

Ian Vaughan


Simple answer: An interrupt can only be interrupted by interrupts of higher priority.

Therefore an interrupt can be interrupted by the kernel or a user task if the interrupt's priority is lower than the kernel scheduler interrupt priority or user task interrupt priority.

Note that by "user task" I mean user-defined interrupt.

like image 43
user703016 Avatar answered Jan 02 '23 10:01

user703016