SoC Blockset™ enables simulation of task executions as they behave on a multicore processor. In multicore simulations, tasks can run simultaneously when assigned to different processor cores. Additionally, assigning lower-priority tasks to unique cores prevents these tasks from getting preempted, giving greater confidence to the final application.
To set the processor core on which a task executes, open the Task Manager block dialog mask. Select a Task from the available tasks. In the task properties, set Core to a nonnegative integer value. During simulation, task instances execute on the specified core, subject to the preemption by other tasks executing on the same core. For more information on task preemption, see Task Priority and Preemption.
SoC Blockset provides a view of the processor cores on the Simulation Data Inspector. This diagram shows the visualization of the core activity relative to the task state.
In the Simulation Data Inspector, the signal
core shows the current task
executing on that core. When the core activity displays as idle, then that core has all
tasks in the waiting state, and the kernel can use that core for background tasks that
are not part of the main application.
If a task instance does not run to completion during the simulation time, the related core status over that instance appears empty in the Simulation Data Inspector display.
This example shows the simulation of multiple tasks, managed by the Task Manager block, execute on multiple cores with display the core activity shown in the Simulation Data Inspector.
This model simulates a software application, running on an ARM processor, with 3 timer-driven tasks. A Task Manager block schedules the execution of the tasks, inside the
Software Application Model Reference block. Tasks 1, with a period of
0.01 seconds, executes on
Core 0. Tasks 2 and 3, with periods of
0.03 seconds, respectively, execute on
Click the Run button to build and run the model. When the model finishes running, open the Simulation Data Inspector display to see the results of the simulation. Select the Core 0 and Core 1 to view the core execution status.
As shown in the Simulation Data Inspector, the core executes either the running task or moves to an idle state, to perform background kernel tasks. Additionally, as two cores are used in this application, high-priority, Task1 executes at the start of each trigger event. Similarly, Task2 and Task3 do not get preempted by Task1. As a result, the application makes better use of the available processor resources.