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.
CocaCola wrote:I have set the handler for the PIT to print something on screen.
However when a loop is entered, the printing is suspended.
It is impossible to pinpoint the cause without prior knowledge of your OS's internals, like how your scheduler works.
For the simplest case of single thread hello world kernel, an IRQ should interrupt the loop, that's how interrupt meant to do.
However, on emulator a tight loop may demand higher workload on the host and thus cause some delay on IRQ logic.
Looks like a newbie mistake.
PIT uses IRQ0 to signal an interrupt, this is the highest priority line and will not be interrupted by lower priority lines such as the keyboard or the CMOS timer, and since you don't signal an EOI mid IRQ handler - the IRQ controller simply thinks you're still processing it. Moreover, you probably disable interrupts when you enter your IRQ handler ( CLI instruction).
halofreak1990 wrote:You should never loop inside an IRQ handler. Rather, loop somewhere outside it, in your main code.
In that way, you can still recieve interrupts.
It is possible that this is the problem! The interrupt handler calls a function that has a loop. So indirectly I loop in the handler.
Nessphoro wrote:Looks like a newbie mistake.
PIT uses IRQ0 to signal an interrupt, this is the highest priority line and will not be interrupted by lower priority lines such as the keyboard or the CMOS timer, and since you don't signal an EOI mid IRQ handler - the IRQ controller simply thinks you're still processing it. Moreover, you probably disable interrupts when you enter your IRQ handler ( CLI instruction).
No, I do not disable interrupts in the handler.
Thanks for mentioning the EOI. The article below states that I should use it in all my handlers, but I'm a bit confused which are "master" handlers and which are "slave" handlers. Slave handlers are the ones associated with higher number IRQs sent to the slave PIC, yes?
CocaCola wrote:
No, I do not disable interrupts in the handler.
actually you do (though you shouldn't have a CLI in your code) -- when an interrupt fires, one of the things the CPU does is automatically disable interrupts -- so until you either iret or STI interrupts will be disabled
as was already mentioned, the correct solution to this is to return from the interrupt (using iret) back to your main code, and loop there
actually, usually the normal way is to end your code in a loop like this:
then all your interrupts will be called from, and return to, this loop (the hlt instruction will also prevent problems with the CPU overheating and other potential issues)
I guess the problem resides in the PIC. You do not send the EOI (EndOfInterrupt) command to the master PIC, so it won't send new interrupts to the CPU.