Task Management with Schedule Editor
SoC processor models use the Task Manager block to manage task priority in simulation and execution. Optionally, you can configure and manage task priorities using the Schedule Editor app in conjunction with the Task Manager block.
Timer-Driven Task Partition
The processor SoC model represents a timer-driven task as an atomic subsystem block. To create a timer-driven task partition, follow these steps:
Add a Subsystem block to the SoC processor model.
Right-click on the Subsystem block and select
Block Parameters (subsystem)
to open the Block Parameters window.In the Main tab, select Treat as atomic unit and set the Schedule as parameter to
Periodic partition
.Set the Partition name parameter to the name of the task.
Set the Sample time (-1 for inherited) parameter to the expected sample time of the timer-driven task.
Put the algorithm into the Subsystem block.
The Schedule Editor tool shows the partition as a periodic partition with the specified partition name and sample time. This image shows a sample of a timer-driven task partition.
Event-Driven Task Partition
The processor SoC model represents an event-driven task as an atomic subsystem block. To create an event-driven task partition, follow these steps:
Add a Subsystem block to the SoC processor model.
Note
When you use task partitioning, the Function-Call Subsystem block in earlier SoC Blockset™ models must be replaced by the Subsystem block.
Right-click on the Subsystem block and select
Block Parameters (subsystem)
to open the Block Parameters window.In the Main tab, select Treat as atomic unit and set the set the Schedule as parameter to
Aperiodic partition
.Set the Partition name to the name of the task.
Put the algorithm into the Subsystem block.
The Schedule Editor tool shows the partition as an aperiodic partition with the specified name. This image shows a sample of an event-driven task partition.
Connect Task Manager to Partitions
In the top-level SoC model, to manage the tasks in the processor SoC module, specified as task partitions in the Schedule Editor tool, follow these steps:
Add a Model block to the top-level model representing the processor.
Click the Model block and select the SoC processor model as the reference model.
Right-click on the Model block and select
Block Parameters (ModelReference)
to open the Block Parameters window.In the Main tab, check Schedule rates and set Schedule rates with to
Ports
.In the top-level model, add a Task Manager block.
Click the Task Manager block and check the Use Schedule Editor ordering parameter.
Add tasks in the Task Manager block for each partition in the processor reference model. Task names must match the partition names. For timer-driven tasks, the period must match the corresponding partition rate.
Connect the Task Manager block output ports to the equivalent partition rate input ports on the processor reference model.
This image shows a sample of the top-level SoC model.
Configure Tasks with Equal Execution Priority
Some designs require multiple timer-driven tasks that have the same period. This
sample model has three partitions,
PeriodicTask
, with
n
PeriodicTask2
and PeriodicTask3
sharing the
same sample time.
Opening the Schedule Editor shows the order of execution of the three
task partitions. The solid arrow shows the dependency where the source,
PeriodicTask2
, runs before the destination,
PeriodicTask3
.
If you reorder the PeriodicTask2
and
PeriodicTask3
partitions, the dashed arrow shows the modified
default order of execution since the source, PeriodicTask2
, runs
after the destination, PeriodicTask3
. This order is honored if these
tasks run on the same core.
Tasks that have the same period can be set to run on different cores. Doing so enables division of the larger task into multiple smaller tasks that run across multiple cores. Since these tasks run in parallel, you can achieve better computation performance.
Note
Using function-call model block representation does not allow two tasks to share a task period.
See Also
Task Manager | Schedule Editor | Timer-Driven Task | Event-Driven Tasks