All of lore.kernel.org
 help / color / mirror / Atom feed
* confusion in interrup handler
@ 2015-01-22  7:25 Er Krishna
  2015-01-22  8:43 ` Adam Lee
  0 siblings, 1 reply; 3+ messages in thread
From: Er Krishna @ 2015-01-22  7:25 UTC (permalink / raw)
  To: kernelnewbies

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 ?


Best regrads,
Krishna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150122/7e07b796/attachment.html 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* confusion in interrup handler
  2015-01-22  7:25 confusion in interrup handler Er Krishna
@ 2015-01-22  8:43 ` Adam Lee
  2015-01-22  9:30   ` sanjeev sharma
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Lee @ 2015-01-22  8:43 UTC (permalink / raw)
  To: kernelnewbies

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
http://adam8157.info

^ permalink raw reply	[flat|nested] 3+ messages in thread

* confusion in interrup handler
  2015-01-22  8:43 ` Adam Lee
@ 2015-01-22  9:30   ` sanjeev sharma
  0 siblings, 0 replies; 3+ messages in thread
From: sanjeev sharma @ 2015-01-22  9:30 UTC (permalink / raw)
  To: kernelnewbies

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.

http://www.linuxjournal.com/article/6916

Regards
Sanjeev Sharma


On Thu, Jan 22, 2015 at 2:13 PM, Adam Lee <adam8157@gmail.com> 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
> http://adam8157.info
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150122/d80e91f8/attachment-0001.html 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-22  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-22  7:25 confusion in interrup handler Er Krishna
2015-01-22  8:43 ` Adam Lee
2015-01-22  9:30   ` sanjeev sharma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.