- A kernel thread that touches an interrupt queue must bracket
- its accesses with calls to intq_lock() and intq_unlock().
- These functions take a lock associated with the queue (which
- locks out other kernel threads) and disable interrupts (which
- locks out interrupt handlers).
-
- An external interrupt handler that touches an interrupt queue
- need not take any special precautions. Interrupts are
- disabled in an external interrupt handler, so other code will
- not interfere. The interrupt cannot occur during an update to
- the interrupt queue by a kernel thread because kernel threads
- disable interrupts while touching interrupt queues.
-
- Incidentally, this has the structure of a "monitor". Normally
- we'd use locks and condition variables from threads/synch.h to
- implement a monitor. Unfortunately, those are intended only
- to protect kernel threads from one another, not from interrupt
+ Interrupt queue functions can be called from kernel threads or
+ from external interrupt handlers. Except for intq_init(),
+ interrupts must be off in either case.
+
+ The interrupt queue has the structure of a "monitor". Locks
+ and condition variables from threads/synch.h cannot be used in
+ this case, as they normally would, because they can only
+ protect kernel threads from one another, not from interrupt