(NB: This is not about interrupting Java/.NET threads, this is about kernel-mode interrupts.)
Hi,
Wikipedia has this to say about Interrupt Threads in the Interrupt handler article:
Interrupt threads
Several operating systems - Solaris, NetBSD, Mac OS X, WinCE and FreeBSD, for example - use different scheme known as interrupt threads. An interrupt handler provided by the device driver is just a high-priority thread which runs with interrupts enabled and, more importantly, may block on mutex. This greatly simplifies locking in the kernel. Also, interrupt thread may be preempted by higher-priority interrupt thread.
What is this technique of Interrupt Threads that FreeBSD (among others) apparently uses? And where can I read more about it?
Thanks in advance. :)
Hardware informs the operating systems of some event with interruptions. They can be raised when an error occurs or when some peripheral has new data available (user pressed a key, a packet arrived on the network, a timer expired, ...). Those interruptions need to be handled quickly by the system (so that it appears responsive).
They are handled by the kernel. Generally, when one such interruption arrives, the currently running code is stopped, and a function of the kernel is called. The interruptions must be acted upon quickly to have a responsive system, so they must not block the kernel waiting for some resource, or do something like that. The classic solution is to have a dumb interruption function that just note the number of the interruption and return, and then in the main loop of the kernel, to check if any interruption occurred and to call the real handler.
As those interruption can be masked (except for non maskable interruption - NMI), the kernel can spawn some threads in kernel mode, and only have them unmasks the interruption and handle them. As those thread are independent of the main kernel thread, they can block, provided there are enough threads to handle the interruptions that may arrive while the thread is blocked.
There's some more technical information in FreeBSD's ithread(9).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With