Interrupts are maintained by a list ofinterrupt_t
objects. Each object contains whether the interrupt has been disabled, the time at which the next interrupt due to this object will be scheduled, whether it is a repeating interrupt and the frequency of repetition.Instruction counts are the units of time used. Instruction counts are implemented as 32b integers.
An interrupt scheduled at "time" x is taken, or at least evaluated, before executing the x+1'th instruction. Therefore an interrupt list command after the x'th instruction will show the interrupt at time x as enabled, and not yet taken.
Two global variables - next_sched_intr_icount (the time at which the earliest interrupt will be scheduled) and next_intr_id keep track of when and which interrupt is the next to be scheduled. This limits the overhead spent on checking-for-scheduled-interrupt. When the icount becomes equal to next_sched_intr_icount,
intr_dispatch
() is called, dispatching an interrupt and setting thepj_irl
orpj_nmi
pins to the appropriate value.After dispatching the interrupt,
intr_dispatch
() checks all interrupts scheduled at that icount.intr_dispatch
disables all interrupts, unless the next interrupt is a repeating interrupt, in which case, it is scheduled.The global variable icount tracks of the number of instructions executed.
Disabling interrupts cannot be enabled. Interrupts are disabled by a user command or by a scheduled non-repeating interrupt.