No Scheduling

A common approach to the problem is to carefully design the system in a way that ensures critical operations get enough CPU time, and that tasks with less timing constraints are interleaved. An example is that instead of the CPU busy-waiting for the 1-second period to then turn off an LED, it uses this time to check the interface buttons at a regular interval. However, this means that the LED task and the button-checking task will be highly dependent upon each other. Adding more tasks to the system requires the same careful integration to prevent altering the overall system performance.

Another approach is to identify all critical tasks and move them to an interrupt or hardware context, i.e., the function is directly supported by an MCU peripheral. Low priority tasks are moved to a while(1) loop where each task gets the necessary time to complete. If the implementation is done correctly, the system is not perceived as slow as all real-time critical tasks are handled immediately using a context switch in the form of interrupts to the CPU. For the developer this implementation is straightforward when the timing requirements are simple, or relatively simple; all low priority tasks will always run in a single pass of the while(1) loop. This scheme is moving towards what is called a cooperative multitasking system since each task cooperatively gives up its CPU time to the next task.

Complexity increases the moment tasks are expected to run at different time periods, or when time critical tasks must be moved from hardware/interrupt context to the while(1) loop. An example is a system in which an LED is blinking each 1 second, the user interface buttons are checked for status change each 250 ms, analog sensors are measured every 2 minutes, etc. Requirements like the ones listed above mean that one pass of the while(1) loop cannot be longer than the required latency in the system, in this example 250 ms for checking the user interface. Additional control software, like state machines, is required to control if the specific task should run at the given time around the loop.