Hi, in my multitasking kernel I am using the PIT as a time base for sleeps (bad idea, I know).
The problem is that if a task keeps calling the scheduler (via int 32 for example), the time starts to drift.
How can I know if an interrupt was a real PIT fire instead of a software interrupt? Is there any way to ask the PIC if it just sent an interrupt?
Cheers,
Gzaloprgm
Distinguishing PIT fires from software interrupts
- gzaloprgm
- Member
- Posts: 141
- Joined: Sun Sep 23, 2007 4:53 pm
- Location: Buenos Aires, Argentina
- Contact:
Distinguishing PIT fires from software interrupts
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Distinguishing PIT fires from software interrupts
Do not use IRQ0 as a system interrupt, but reserve a system call for thatHow can I know if an interrupt was a real PIT fire instead of a software interrupt?
Re: Distinguishing PIT fires from software interrupts
Hi,
However, a much better idea is to set the DPL in the IDT entry to zero for all IRQs and exceptions. In this case if any user-level code attempts to call the IRQ handler (or exception handler) using a software interrupt then it'll trigger a general protection fault (but if an genuine IRQ or exception occurs then CPU will still start the interrupt handler, without triggering a general protection fault).
Cheers,
Brendan
You can check if the corresponding flag in the PIC's "in service register" is set - if this flag isn't set then you know the PIC didn't send the IRQ.gzaloprgm wrote:How can I know if an interrupt was a real PIT fire instead of a software interrupt? Is there any way to ask the PIC if it just sent an interrupt?
However, a much better idea is to set the DPL in the IDT entry to zero for all IRQs and exceptions. In this case if any user-level code attempts to call the IRQ handler (or exception handler) using a software interrupt then it'll trigger a general protection fault (but if an genuine IRQ or exception occurs then CPU will still start the interrupt handler, without triggering a general protection fault).
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.