Real-Time Systems Development

Small cyclic systems are based on the test-and-skip looping scheme described in the last chapter but include interrupt and 'burn' routines to maintain accurate loop timing. This chapter shows how they can be implemented using a function pointer table, with an associated dispatcher routine. The function names are all held in an array, and evoked in round-robin sequence by the dispatcher code. This simple scheme enables subsequent modifications to be readily undertaken. In conclusion, an example keypad application is described.
The activity of a basic cyclic scheduler is illustrated below. Several functions are called in a prearranged sequence. In academic terms, the loop tasks are submitting themselves to a regime of 'cooperative scheduling', meaning that the programmer decides when a task will hand on to the next, with little scope for dynamic, run-time priority modification. At the end of the list, a special idle or burn function spins round in a tight loop testing a tick flag status bit. This flag is set once every 20 ms by an interrupt service routine. As soon as the burn task sees that the flag has been set, it stops spinning and returns to the start of the main loop, clearing the tick flag in readiness for the next burn. In this simple way, it is possible to be sure that each of the tasks runs at a rate of 50 Hz, once every 20 ms.
Small cyclic executives do...