Operation Manual
Human-computer interfacing
128
Notes:
The second method is an example of “polling”. It tends to waste a lot of your time
by frequently checking the phone when there is nobody there. It also takes time to
swap from one task to the other. This is what you would have to do if the phone
had no ringtone. Polling is the method that is used when events occur frequently
and must be handled in a timely manner.
The third method is an example of “multitasking”. The first person can
concentrate on their work on the computer. The second person could be checking
(polling) the phone all the time and pass messages to you as and when needed.
The problem is that there is not always a second person around. Don’t worry –
operating systems such as Linux on the Raspberry Pi do make it possible for you
to do multitasking, even though there is only one processor.
Embedded applications
An embedded application is where a computer is built into another device. For
example, a Freeview box for a TV or a satnav in a car. If you compare a desktop
PC with a Raspberry Pi, you can see that a desktop PC is not suitable as a
component to build into small devices, unlike a Raspberry Pi. A standard PC does
not normally have any GPIO interfaces fitted either! A Raspberry Pi is much more
versatile in this regard than a desktop PC.
Real-time applications
A lot of real-world control applications are said to function in “real time”. For real-
time applications, it is often necessary to be able to read inputs, process them
and produce outputs thousands of times a second. The rate of this processing
has to be predictable – one calculation in a fixed timeframe. For example, a CD
has a sample rate of 44.1 kHz – that means that for each data sample point, you
only have 1/44100 seconds (22.6 µS) to do all the processing! In a multitasking
operating system, such as Linux on the Raspberry Pi, you cannot guarantee that
your program will have full control of the CPU during those few microseconds
– the operating system may be busy, communicating on the network port,
for example.
When there is an irregular sample rate on input data, this is called “jitter”. The
predictable timing accuracy that is required needs either dedicated hardware or
special real-time operating systems and low-level programming languages, such
as C or Assembler. The operating systems currently available on the Raspberry Pi
are not really suitable for real-time applications. Fortunately, the Raspberry Pi
does include a C compiler (called GCC) if you want to learn how to write a lower-
level program.