Concurrency handling

Sequential control

An embedded system can use sequential control, meaning that the developer creates a list of tasks that the device executes one after the other. In this case, the system deals with one task at a time and does not start the next one until the previous one has been completed. This control mode is not suitable for more complex tasks, as for example, creating such a list of commands for two lights simultaneously blinking at different intervals is not possible. Proper multitasking is required.

Multitasking

When a pastry chef makes a cake, they rarely perform a single task at a time. While the oven is preheating, they measure the ingredients and separate the eggs. If they have to wait a few minutes while their colleague washes a bowl, they start preparing the cream. Starting each task only after completing the previous would make the process much longer. It is necessary to perform tasks simultaneously, but since the pastry chef can only be in one place at a time, they use their time efficiently and switch between tasks. Similarly, a CPU core can only execute one instruction at a time, but it can create the illusion of parallelism by switching between tasks very quickly. For the user it seems as if multiple programs are running simultaneously.

Operating system

No operating system is required for sequential control. However, if the processor has to handle multiple tasks simultaneously, an additional program is needed to decide when to give tasks resources, when to run or stop tasks, and which task should be handled next when there are multiple of them waiting. This supervisory program is called an operating system in embedded systems and other devices.