(1) Control Systems are Event-Driven
Pressing a button, receiving data, detecting a change by a sensor, etc. A trigger that activates some form of processing is called an event. In control systems, events occur occasionally or periodically. A system in which necessary processing is activated when an event occurs is called an event-driven system.
(2) Detecting an Event and Activating the Corresponding Processing
Occurrence of an event in a control system is indicated physically as a signal change, such as generation of a potential pulse. There are several ways for microprocessors to detect signal changes. One way is to use the interrupt functions of the microprocessors. In this way, a specified program is activated when the signal level on the interrupt pin changes. Another way is to execute a program that monitors the signal level (high or low) on the target pin and activates specified processing when a signal change is detected. This monitoring operation is called polling.
(3) Limited Time for Each Event Processing
Most processes in control systems are not allowed to start or end at an unspecified time; they have time limits. Each event requires a sequence of operations that input and output data within a limited period. The entire system works through combinations of these sequences of operations. A system that can respond within a limited period is called a real-time system. This does not always mean a high-speed system, but means that processing must be completed within a specified period. The period length depends on the target of control; for example, several hundred milliseconds for human perception, one-hundredth of a second for clock accuracy, or several microseconds for hardware control. In a system that includes different control targets, processing should be appropriately switched depending on the event.
(4) Hard Real-Time Processing and Soft Real-Time Processing
There are two types of time limits; one type affects the system function if the limit is violated, and the other type does not seriously affect the function even if processing is slightly delayed. Examples of the former type are found mainly in hardware control, such as time limits on input signal detection or signal output. Examples of the latter type are found in man-machine interfaces, such as key or display response times. Processing that should strictly observe a time limit is called hard real-time processing, and the other type of processing is called soft real-time processing. Embedded systems need to execute both hard real-time processing and soft real-time processing at the same time.
(5) Control Systems are Multitasking
Many microprocessor-embedded systems need to execute multiple event processes in one CPU at the same time and a sequence of operations should sometimes be done in parallel. However, a CPU cannot execute multiple instructions at the same time. How can a single CPU process multiple operations in parallel?
- Using the processing wait time
In a processing sequence, various wait states are generated, such as input wait, output completion wait, time wait, or processing completion wait. The CPU does nothing during these wait periods. Assigning the CPU to some other event processing (switching the processing program) during a wait state enables parallel execution; that is, processing while other processing is being done is effectively realized. The unit for CPU assignment is called a task, and executing multiple processes in parallel is called multitasking.
Such parallel execution reduces the idle time and increases the working time of a CPU. - Switching processing periodically
This method forcibly switches tasks periodically even if no wait state is generated, and executes multiple tasks intermittently in parallel.
(6) Priority Processing is Essential for Hard Real-Time Processing
Hard real-time processing, where incorrect timing has fatal effects on the system, does not work at all if switching between processes has to wait until the current process enters a wait state or until a specified loop time is reached. Priority processing is necessary to assign a priority order to waiting processes. This priority processing is called priority-based switching. In addition, the current process should be suspended to switch to another process when necessary. This priority processing is called preemptive switching.
*Real-time OSs, typified by uITRON, satisfy the above task operation requirements for embedded systems. A real-time OS that has the above functions can be described as follows:
Preemptive, priority-based, multitasking real-time OS
You can often find such a phrase in catalogues of real-time OS products.
In these features, the real-time OS differs from UNIX or a personal-computer OS, which tries to assign the CPU to multiple users or applications equally. As described above, the real-time OS is designed primarily to achieve real-time processing.