confusion in interrup handler

sanjeev sharma sanjeevsharmaengg at
Thu Jan 22 04:30:29 EST 2015

Hello All,

I second Adam Lee.

Code running in interrupt context is unable to sleep, or block, because
interrupt context does not have a backing process with which to reschedule.
Therefore, because interrupt handlers are not associated with a process,
there is nothing for the scheduler to put to sleep and, more importantly,
nothing for the scheduler to wake up and this it the reason why we can't
sleep inside interrupt context.This is totally design constraint.

here is some more detail for reference.

Sanjeev Sharma

On Thu, Jan 22, 2015 at 2:13 PM, Adam Lee <adam8157 at> wrote:

> On Thu, Jan 22, 2015 at 12:55:12PM +0530, Er Krishna wrote:
> > Hi All,
> >
> > Pls help me here to understand the following scenario:
> >
> > As we know, we cant sleep inside interrupt handler. But what is the
> reason for
> > it?
> >
> > If I put sleep inside the handler code handler, handler code will not
> complete
> > and none of the process on that particular processor will ever will
> execute. So
> > it will be kind of deadlock. But what if the system is having multiple
> > processors ? Is it safe here to sleep ? If not what is the reason ?
> This is a very good question. My thoughts(maybe not right):
> 1, can't sleep inside a interrupt handler, it's kind of by design but
> not a hardware limit.
> 2, the scheduler and IRQ system need to be re-designed to support sleep
> inside interrupt handlers, like to support the IRQ handler as a schedule
> unit, handle IRQ handlers by a certain kernel thread other than in
> processes' context. Otherwise handler code won't complete and the
> process context(like those holding locks) will deadlock, this answered
> your question, still not safe.
> 3, what if the sleep inside interrupt handlers are supported as "thought
> 2"? The scheduler will be far too complicated, system will become very
> unstable because IRQs are so not real time then.
> --
> Adam Lee
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Kernelnewbies mailing list