Why an Interrupt Handler Must Never Sleep
An interrupt handler runs in a borrowed moment with no process behind it, so there is nothing for the scheduler to put to sleep and nothing to wake up later. That makes anything that might wait, such as allocating memory that could block, taking a sleeping lock, or copying to user memory, forbidden inside one. Doing it anyway does not just fail; it can freeze the machine, which is why kernel programming has a whole vocabulary about atomic context.
Questions this Concept answers
- Why is there nothing for the scheduler to put to sleep when an interrupt handler runs?
This Concept is waiting for its first lesson!
An interrupt handler runs in a borrowed moment with no process behind it, so there is nothing for the scheduler to put to sleep and nothing to wake up later. That makes anything that might wait, such as allocating memory that could block, taking a sleeping lock, or copying to user memory, forbidden inside one. Doing it anyway does not just fail; it can freeze the machine, which is why kernel programming has a whole vocabulary about atomic context.
Are you a teacher? Sign in to start contributing.
Sign In