So far, we've only mentioned tasks very casually, but what is a task, really? An easy way to think about a task is that it is just another main loop. In a preemptive RTOS, there are two main differences between tasks and super loops:
- Each task receives its own private stack. Unlike a super loop in main, which was sharing the system stack, tasks receive their own stack that no other task in the system will use. This allows each task to have its own call stack without interfering with other tasks.
- Each task has a priority assigned to it. This priority allows the scheduler to make decisions on which task should be running (the goal is to make sure the highest priority task in the system is always doing useful work).
Given these two features, each task may be programmed as if it is the only thing the processor has to do. Do you have a single...