This FPGA design example shows how you can use interrupt services to associate threads to wait for specific interrupt events. The thread associates an ISR onto an interrupt source, and then waits for interrupt notification. In the example a 1kHz source is used for interrupt generation. The function
pthread_interrupt_timedwait() is used to make
n threads go on wait for periods of
1,
2, ...,
n seconds, and then compare the results with standard
clock_ms().
Posix interrupts are used at the driver level to make IO requester threads sleep and to only wake up after a certain I/O interrupt event has taken place. In many cases this is a desirable situation since you don't want to spend CPU time in unnecessary sleep or yield operations. Mutex is used to protect resources during multi-threading.
The result is displayed in the terminal instrument in text. The TSK3000, Terminal Instrument and SRAM controller are used in this example.
Altium Designer projects included in this download:
- Thread_Interrupts.PrjFpg
- Thread_Interrupts.PrjEmb