Assigns an interrupt handler to the specified interrupt level, and optionally makes the calling thread the interrupt thread for that level. It is not necessary for the handler to have a thread.
BOOLEAN SetRtInterruptHandler( WORD wLevel, BYTE byMaxInt, LPPROC lpfnHandler, );
wLevel
byMaxInt
lpfnHandler
The number of outstanding SignalRtInterruptThread requests that the handler can make before the associated interrupt level is disabled generally corresponds to the number of buffers used by the handler and interrupt thread.
If the byMaxInt parameter is non-zero, then the calling thread becomes the interrupt thread.
The interrupt handler has this general form:
__INTERRUPT void InterruptHandler(void)
{ // TODO: any local variables are declared here. __INTERRUPT_PROLOG(); // Before EnterRtInterrupt the data segment cannot be used, // so we have to obtain the level dynamically. EnterRtInterrupt(GetRtInterruptLevel()); // Interrupt handling statements __INTERRUPT_RETURN(); }
Note that any pointer to a variable on the stack in the interrupt handler cannot be dereferenced. This is because the interrupt handler runs in a privileged context which makes it impossible for the compiler to generate a correct stack-based address. Any attempt to do so will result in a page fault.
To uninstall an interrupt handler call ResetRtInterruptHandler. If a handler has an associated interrupt thread then an implicit call to ResetRtInterruptHandler is made on exit from the current process. If there is no interrupt thread then an explicit call to ResetRtInterruptHandler must be made before process termination. Failure to do so can cause system instability.
TRUE
FALSE
E_OK 0000
E_LIMIT 0x0004
byMaxInt
contains a value other than 0 (zero).
E_CONTEXT 0x0005
E_PARAM 0x8004
wLevel
is invalid.
E_BAD_ADDR 0x800F
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/rtbase.h | rt.h | rt.lib |