views:

1571

answers:

4

I recently started diving into low level OS programming. I am (very slowly) currently working through two older books, XINU and Build Your Own 32 Bit OS, as well as some resources suggested by the fine SO folks in my previous question, How to get started in operating system development.

It could just be that I haven't encountered it in any of those resources yet, but its probably because most of these resources were written before ubiquitous multicore systems, but what I'm wondering is how interrupts work in a multicore/multiprocessor system.

For instance, say the DMA wants to signal that a file read operation is complete. Which processor/core acknowledges that an interrupt was signaled? Is it the processor/core that initiated the file read? Is it whichever processor/core that gets to it first?

Sorry if this is a stupid question, I'm very new to this.

+1  A: 

In the old days the interrupt went to all processors. In modern times some kinds of hardware can be programmed by an OS to send an interrupt to one particular processor. Of course if you could choose a processor dynamically instead of statically, you wouldn't want to send the interrupt to whichever processor initiated the I/O, you'd want to send it to whichever processor is least burdened at the present time and can most efficiently start the next I/O operation, and/or whichever processor is least burdened at the present time and can most efficiently execute the thread that was waiting for the results.

Windows programmer
Thanks for the answer! Do you happen to know if the x86/x86-64 allow both approaches?
Giovanni Galbo
+1  A: 

I don't know the answer to your question, but I'd highly recommend taking a look at the Intel® 64 and IA-32 Architectures Software Developer's Manual, volume 3, chapter 5. It's big and detailed, containing more than you ever wanted to know about the x86 architecture.

Adam Rosenfield
awesome resource, which I'll definately use when I'm actually ready to start programming my OS!
Giovanni Galbo
I'd also recommend volume 3, chapter 9 which deals with the APIC (Advanced Programmable Interrupt Controller). It gives more details of how interrupts actually reach the each thread.
Nathan Fellman
+3  A: 

Looking into the IoConnectInterrupt function you can find the ProcessorEnableMask that will select the cpu's that allowed to run the InterruptService routine (ISR).
Based on this information i can assume that somewhere in the low level (see Adam's post) it's possible to specify where to route the interrupt.

On the side note file operation is not really related to the interrupts and/or dma directly. File operation is file system concept that translated to something low level depend on which bus you filesystem located it might be IDE or SATA disk or it might be even usb storage in this case sector read will be translated to 3 logical operation over usb bus, there will be interrupt served by usb host controller driver, but it's not really related to original file read operation, that was probably split to smaller transaction any way.

Ilya
Thank you. I wish there was a way to accept multiple answers, but the real life examples cleared it up for me. Also thanks for the note on file reads.
Giovanni Galbo
+2  A: 

this article http://www.alexandersandler.net/smp-affinity-and-proper-interrupt-handling-in-linux explains how interrupts in smp machines are handled by linux

Matthias