next up previous contents
Next: Primitive Synchronization Up: Reference of Primitive Thread Previous: Primitive Thread Manipulation

Interrupt Service Routines

# include <ucr/ucr.h>
extern void set_isr(unsigned vector, void (*fun)(void*, unsigned), void*arg);
extern bool isr_hot_flag();

Use this function to attach a service routine to an interrupt. The vector is the identifier for the interrupt as understood by the underlying interrupt dispatch hardware. The interrupt dispatching capabilities of the CPU determine what these numbers mean.

Some targets require interrupt chaining. uCR supports this by keeping a limited table of isr pointers and calling all the registered functions each time an interrupt is called.

Although it is not usually necessary, it is possible for a piece of code to know that it is running on behalf of an interrupt by calling the isr_hot_flag() function. This returns true if the CPU is executing interrupt service routines, false otherwise.

Stephen Williams