1A collection of articles on kernel internals, please add to this 2 3------------------------------------------------------------------------------ 4IRQ level 5------------------------------------------------------------------------------ 6 7IRQ level (IRQL) is a per-processor state in ReactOS used to coordinate 8execution between ISRs and between threads. There are several levels 9 10 PASSIVE_LEVEL, APC_LEVEL: The normal level for user mode and most 11 kernel mode code. At the moment APC_LEVEL is unused. 12 13 DISPATCH_LEVEL: At this level all irqs are still allowed but thread 14 rescheduling on the current processor is disabled. This is used by 15 the spinlock synchronization primitive to implement its uniprocessor 16 semantics (multiprocessor is more complex). It is also used for some 17 other forms of synchronization, DPCs for example. Many APIs are 18 unavailable at this IRQL, usually those that might have to wait. It 19 is recommended that you don't spend too much time at this IRQL 20 otherwise system responsiveness will be reduced. 21 22 > DISPATCH_LEVEL: Each irq is assigned a priority (which will be 23 greater than DISPATCH_LEVEL). At an irq's priority level that irq, 24 lower priority irqs and thread rescheduling are disabled. Higher 25 priority irqs can still run. Very few APIs are available at IRQLs 26 greater than DISPATCH_LEVEL. 27 28 HIGH_LEVEL: All irqs are disabled. 29 30------------------------------------------------------------------------------- 31DPCs 32------------------------------------------------------------------------------- 33 34It is a design goal not to spend too much time in ISRs, for this reason 35ISRs should postpone most processing till it can run at a lower IRQL. The 36mechanism for this is a Deferred Procedure Call (DPC). When a DPC object is 37created, it is associated with a function. The DPC object can then be inserted 38in the DPC queue from an ISR. If the IRQL on return from the ISR is less than 39DISPATCH_LEVEL the DPC queue will be drained, otherwise this will happen when 40the IRQL level drops below DISPATCH_LEVEL or the processor becomes idle. When 41the DPC queue is drained each DPC object is removed and the associated 42function is called at DISPATCH_LEVEL. A DPC object can only be inserted once, 43further insertions before it is removed will have no effect. 44