Real-Time Workshop | ![]() ![]() |
Multitasking and Pseudomultitasking
In a multitasking environment, the blocks with the fastest sample rates are executed by the task with the highest priority, the next slowest blocks are executed by a task with the next lower priority, and so on. Time available in between the processing of high priority tasks is used for processing lower priority tasks. This results in efficient program execution.
See Multitasking System Execution for a graphical representation of task timing.
In multitasking environments (i.e., a real-time operating system), you can define separate tasks and assign them priorities. In a bare-board target (i.e., no real-time operating system present), you cannot create separate tasks. However, Real-Time Workshop application modules implement what is effectively a multitasking execution scheme using overlapped interrupts, accompanied by manual context switching.
This means an interrupt can occur while another interrupt is currently in progress. When this happens, the current interrupt is preempted, the floating-point unit (FPU) context is saved, and the higher priority interrupt executes its higher priority (i.e., faster sample rate) code. Once complete, control is returned to the preempted ISR.
The following diagrams illustrate how mixed-rate systems are handled by Real-Time Workshop in these two environments.
Figure 8-2: Multitasking System Execution
Figure 8-3 illustrates how overlapped interrupts are used to implement pseudomultitasking. Note that in this case, Interrupt 0 does not return until after Interrupts 1, 2, and 3.
Figure 8-3: Pseudomultitasking Using Overlapped Interrupts
![]() | Executing Multitasking Models | Building the Program for Multitasking Execution | ![]() |