32 Real-time systems development
at the end, to raise and lower the voltage on a single bit of an output port.
The run-time variation will show up as a horizontal shudder or jitter on the
back edge of the pulse. This is due to intervening interrupts and unavoid-
able uncertainty in the execution of the IF/ELSE selections within the code.
Some specialist application areas deal with this run-time uncertainty by
carefully padding out the code to match up each arm of all the IF/ELSE
statements. Alternatively, the hardware can be used to drive a group of inter-
rupt service routines, one for each task, but this will never be satisfactory
in the long run because it is intrinsically inflexible, beyond the program-
mer’s control. Also, doubt has been expressed on the safety of systems which
rely too heavily on interrupts. Testing all the combinations and situations
in which interrupts can occur is impossible, leaving the nagging issue of
reliability.
The task loop also imposes a minimum response latency on I/O activity.
Taking the average, a device will have to wait one half of a loop period before
its associated task comes round to deal with the request. This constraint may
impose too fast a loop frequency, reducing the amount of useful processing
that a task can complete each cycle. The quick fix of splitting loop tasks
into several phases, each to be executed on subsequent passes through the
loop, is not to be pursued. A further caution regarding this implementation
plan involves the risk of tasks blocking or crashing; however unlikely the
external events and circumstances, however well tested your code, this will
occur (trust me). Unfortunately, a loop task crashing leads to a catastrophic
failure of the whole system, even if the problem, trivially, only involved a
single input channel.
2.5 Interrupt-driven tasks
A fuller description of the details of interrupt handling will be presented in
Chapter 3. So this paragraph simply introduces the topic as it relates to
elementary tasking techniques. Most CPUs are provided with one or more
interrupt request lines which play an important part in keeping the computer
system on its toes and providing a timely service to all its attached devices.
Using the interrupt facilities, it is possible to arrange for specially written
subroutines to be evoked by externally triggered interrupt signals. So the
interrupt signal arriving at the CPU forces it to stop executing the current
Brr Brr
Brr Brr!
Telephonic interruptions

Get Real-Time Systems Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.