<div dir="ltr"><div><span style="font-family:arial,helvetica,sans-serif">Hello All,<br><br></span></div><div><span style="font-family:arial,helvetica,sans-serif">I second Adam Lee.<br></span></div><div><span style="font-family:arial,helvetica,sans-serif"><br></span></div><span style="font-family:arial,helvetica,sans-serif">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.<br></span><div><font><span style="font-family:arial,helvetica,sans-serif"><span style="color:rgb(34,34,34);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:19.5px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:rgb(255,255,255)"><br></span></span></font></div><div><font><span style="font-family:arial,helvetica,sans-serif"><span style="color:rgb(34,34,34);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:19.5px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:rgb(255,255,255)">here is some more detail for reference.<br><br><a href="http://www.linuxjournal.com/article/6916">http://www.linuxjournal.com/article/6916</a><br><br></span></span></font></div><div><span style="color:rgb(34,34,34);font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:19.5px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:rgb(255,255,255)"><font><span style="font-family:arial,helvetica,sans-serif">Regards<br>Sanjeev Sharma</span></font><br></span></div><div><span style="color:rgb(34,34,34);font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:19.5px;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:rgb(255,255,255)"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 22, 2015 at 2:13 PM, Adam Lee <span dir="ltr"><<a href="mailto:adam8157@gmail.com" target="_blank">adam8157@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Jan 22, 2015 at 12:55:12PM +0530, Er Krishna wrote:<br>
> Hi All,<br>
><br>
> Pls help me here to understand the following scenario:<br>
><br>
> As we know, we cant sleep inside interrupt handler. But what is the reason for<br>
> it? <br>
><br>
> If I put sleep inside the handler code handler, handler code will not complete<br>
> and none of the process on that particular processor will ever will execute. So<br>
> it will be kind of deadlock. But what if the system is having multiple<br>
> processors ? Is it safe here to sleep ? If not what is the reason ?<br>
<br>
</div></div>This is a very good question. My thoughts(maybe not right):<br>
<br>
1, can't sleep inside a interrupt handler, it's kind of by design but<br>
not a hardware limit.<br>
<br>
2, the scheduler and IRQ system need to be re-designed to support sleep<br>
inside interrupt handlers, like to support the IRQ handler as a schedule<br>
unit, handle IRQ handlers by a certain kernel thread other than in<br>
processes' context. Otherwise handler code won't complete and the<br>
process context(like those holding locks) will deadlock, this answered<br>
your question, still not safe.<br>
<br>
3, what if the sleep inside interrupt handlers are supported as "thought<br>
2"? The scheduler will be far too complicated, system will become very<br>
unstable because IRQs are so not real time then.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Adam Lee<br>
<a href="http://adam8157.info" target="_blank">http://adam8157.info</a><br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</font></span></blockquote></div><br></div>