Hi,
BenLunt wrote:
Hi everyone. My turn to ask a question rather than answer
I have been reading about the APIC (Advanced Programmable Interrupt Controller) and know that it is a necessity for multiprocessor systems if your OS is capable of using more than one processor. However, my question is, other than the included timer that comes along with it, is there any advantage to detecting, initializing, and using the APIC on a uniprocessor system or an OS that is only uniprocessor capable?
As I see it, you still have to use the (emulated) 8259 for IRQ's and still only have the 15 vectors to choose from.
If you are going to use MSI's, I guess you need to have an APIC?
Anyway, what advantages does the APIC have in a uniprocessor system, besides the extras such as the timer?
If you only support one processor, do you need to even detect and initialize the APIC?
Now, to even confuse you and myself even more, the above is considered the Local APIC. What about the I/O APIC?
Advantages of local APIC (instead of "nothing") for single-CPU:
- Provides the single best (for precision and overhead) timer that will ever exist
- Potentially useful for power management (to determine if/when the CPU has entered thermal throttling mode)
- Potentially needed for profiling and debugging (performance monitoring counter overflows, etc)
- "Send IPI to self" might (or might not) be useful or convenient for "deferred procedure call" functionality in restricted code (e.g. IRQ handlers)
Advantages of using IO APIC (instead of PIC) for single-CPU:
- Lower overhead interface (fast memory mapped registers rather than slow legacy IO ports)
- Needed for MSI
- Typically more IRQ lines (and less IRQ sharing, even without MSI). This means less overhead when an IRQ occurs (because you don't need to ask multiple device drivers to tend to their device)
BenLunt wrote:
The I/O APIC, from what little reading I have done so far, does allow up to 24 vectors. Eight plus one more than the 8259.
No; a single IO APIC with 24 inputs is just "relatively more common".
Nothing (no standard, etc) prevents a system from having (e.g.) 12 separate IO APICs with one input per IO APIC (a combined total of 12 inputs, where some legacy ISA stuff can't be connected and lots of PCI IRQ sharing would happen); and nothing prevents a system from having a single IO APIC with 128 inputs; and nothing prevents a system from having one IO APIC with 4 inputs, another IO APIC with 8 inputs and a third IO APIC with 12 inputs (a combined total of 24 inputs).
BenLunt wrote:
In a uniprocessor or multiprocessor system, it is probably an advantage to detect, initialize, and use the I/O APIC so that you can now use 24 IRQ lines?
There are advantages; but there's also disadvantages - mostly, that you can't easily figure out which PCI device uses which IO APIC input without using a (disgustingly overcomplicated) APCI AML interpreter. Fortunately, MSI avoids this (so if you're very lucky and every device supports MSI, then...).
Cheers,
Brendan