Chained interrupts without ISRs

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Chained interrupts without ISRs

Post by Colonel Kernel »

I've been thinking about how to design my microkernel's interrupt handling scheme lately, and I ran across this conundrum.

It seems that many microkernels deal with interrupts by sending messages to threads in user-mode drivers rather than letting the drivers install ISRs. This keeps the kernel nice and simple, but I thought of a problem -- what if your kernel is running on a device with very few hardware IRQs? A smart phone, for example.

In a "macrokernel" or monolithic kernel (or a microkernel with kernel-mode drivers, although I hesitate to call that a microkernel), several ISRs could be registered for the same IRQ, and they would be called in sequence (Symbian OS does this, for example). Can this be done efficiently with a message-passing architecture and user-mode drivers? I doubt that it can, but maybe the more experienced among us know better...?
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Chained interrupts without ISRs

Post by Brendan »

Hi,
Colonel Kernel wrote:Can this be done efficiently with a message-passing architecture and user-mode drivers? I doubt that it can, but maybe the more experienced among us know better...?
Regardless of what you do (for single_CPU), sending messages is always going to be less efficient than ISRs.

The best method I can think of (for single CPU) is to send the "IRQ notification" to one device driver at a time until one of them replies "It was me!". This would reduce the number of messages that need to be sent, especially if the OS sorts the list of device drivers in order of how often they are responsible for the IRQ.

For multi-CPU situations this can be extended such that for N CPUs N messages get sent to N device drivers at once. This way all CPUs can attempt to handle the same IRQ at the same time (better for interrupt latency).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Chained interrupts without ISRs

Post by Pype.Clicker »

well, my approach is rather hybrid. I keep 'ISR handlers' in the kernel and 'hardworking' at userlevel. That means for instance that Clicker "microkernel" has a ISR handler in a module that reacts on mouse IRQs and perform basic task of decoding mouse packets. Once they're decoded, they're delivered as a message to the process that listen to the mouse device.

Same thing occurs with disk or network IRQs: data are retrieved at kernel (thus without incurring a process switch) and when done, a message notifies the requestor (e.g. the filesystem server or the network stack server) that requested operation is completed.
Post Reply