Interrupt Service Routine

Hey!
Why can’t the Interrupt Serivce Routine-ISR block or call any kernel functions that might result in blocking ?

On Fri, 9 Sep 2016 04:41:18 -0700 (PDT), saumitra kapoor
<saumitrakapoor@gmail.com> declaimed the
following:

Hey!
Why can't the Interrupt Serivce Routine-ISR block or call any kernel
functions that might result in blocking ?

  Quick&Dirty answer: because any operation that can block needs to be
woken up later when it is unblocked... That wake up is usually done as part
of some interrupt handling (clock tick for preemption and/or timeout; I/O
operation completion, etc.)... But since you are in an ISR, other
interrupts are disabled and do not trigger until your ISR finishes -- and
your ISR is not going to finish until something else does... DEADLOCK

  Longer...

  ISRs are supposed to be very short/fast -- they respond to something
with a deadline (fetch a character from I/O port, say, and stuff it into a
circular buffer). If more complex processing is needed, the HW ISR should
set some event flag which a lower priority software process (SW ISR/system
service) can then handle.

  This forms a hierarchy:

HW interrupts: highest priority, short&fast, commonly not preempted
SW interrupts: medium priority -- can be preempted by HW interrupt, more
complex processing
"user" tasks: lower priority -- preempted by any of the above, the real
work
"IDLE": lowest priority, only runs when all of the above are not active
(user tasks blocked for I/O, and no HW/SW interrupts triggered)

{depending on the hardware/software, there may be multiple priorities
within each of the HW/SW/user levels, and a higher priority HW interrupt
could preempt a lower priority HW interrupt... Though on much of the
hardware I've played with, the common technique is that ALL interrupts are
disabled on entry to a HW ISR}