Learning Linux wrote:
Hi,
> I have a very basic doubt here ... what makes it impossible to sleep
> in an ISR? I mean, I know that the kernel preemption is disabled and
> the kernel will panic, but I could not understand why?
The impossibility to sleep comes as a natural consequence of the fact
that ISRs have to be fast.
An ISR has to be fast in order to allow other system tasks to happen.
Otherwise it will do a lot of work (like busy waiting) and any other
interrupts will fail to get handled. That would completely render the
system unusable.
Agreed.
On the other hand, when you sleep in a given context, the scheduler is
invoked. That means that the ISR routine would be replaced by a process
from the scheduler's queue(s). But how would you ever know to reschedule
the ISR? After all, it is asynchronous.
Uh, this is what I have my doubt about. Yes, the scheduler may try to
replace the current process (already interrupted by the ISR) with
another process.
So, what is the problem with that? Could you please elaborate on the
part "how would you ever know to reschedule the ISR? After all, it is
asynchronous"?
Well, the ISR code has to be resumed at some point doesn't it? How would
you know how to "get back" at executing it? There's no ISR scheduling
queue, as there is no process. An ISR can interrupt any given process
(that's what I meant by asynchronous).
And even if that weren't a problem you would still have to deal with
another problem: if an important interrupt (like the timer interrupt)
would sleep and would (somehow) manage to get rescheduled, you would
lose any notion of time within that system; it will inconsistent, and it
will break all other subsystems (like scheduling) (the process time
slice would lose its meaning)
Razvan
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ