everything is time-critical, it must be the master.
Imagine being in a crowded restaurant with
friends and placing an order for drinks. The waiter
leaves, then later returns weaving between tables,
holding the drinks on a tray above his head. It
makes sense that he is in control, not you — even
though you’re the customer. He judges the time-critical swerves and swoops to make it safely back
to your table.
The UI controller PIC must request to send a
message to the MIDI controller PIC, which when
ready acknowledges with a handshake. The MIDI
controller PIC controls the clock signal that ‘pulls’ in
the message and will possibly interrupt reception to
do other time-critical tasks.
The type of scheduling used to manage tasks in
the MIDI controller PIC is called round-robin with
interrupts. This is a scheme that balances the need
for simplicity against the demands of immediate real time
The main loop shown in Figure 11 can be thought
of as a spinning wheel, where each task on the wheel is
traversed in series (round-robin).
The ISR handles received and transmitted bytes,
routing them to and from associated buffers. The tasks are
simple and so critical that they are handled immediately in
The ISR also sets a flag when the timer ‘ticks,’ plus sets
the song position variable. However, the actual processing
of the tick occurs in the round-robin loop.
Beware the Buffer
Buffers are admittedly essential in many systems to
smooth demand peaks, but need to be used with caution
in real time systems.
They smack of procrastination: Doing things when it
suits you and alleviating the immediate stress. However,
this doesn’t help when there’s a tight schedule!
Also, putting things off can just postpone throughput
issues. If the rate of emptying water from a leaking boat is
less than the rate of water being taken on board, then the
boat will eventually sink!
The height of the boat is like the buffer size. In real
time systems, we must design for a shallow boat to ensure
tasks are completed promptly and must ensure we empty
water from the boat quickly! It’s easy to think all we need
to do is slap in big buffers to overcome real time issues.
; FIGURE 12. Spreading the load with parallel processing.
; FIGURE 13. Three different command ‘languages.’
32 September/October 2018