Main Content

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:

  1. Add a Subsystem block to the SoC processor model.

  2. Right-click on the Subsystem block and select Block Parameters (subsystem) to open the Block Parameters window.

  3. In the Main tab, select Treat as atomic unit and set the Schedule as parameter to Periodic partition.

  4. Set the Partition name parameter to the name of the task.

  5. Set the Sample time (-1 for inherited) parameter to the expected sample time of the timer-driven task.

  6. 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.

Schedule Editor Timer Driven Task

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:

  1. 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.

  2. Right-click on the Subsystem block and select Block Parameters (subsystem) to open the Block Parameters window.

  3. In the Main tab, select Treat as atomic unit and set the set the Schedule as parameter to Aperiodic partition.

  4. Set the Partition name to the name of the task.

  5. 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.

Schedule Editor Event Driven Task

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:

  1. Add a Model block to the top-level model representing the processor.

  2. Click the Model block and select the SoC processor model as the reference model.

  3. Right-click on the Model block and select Block Parameters (ModelReference) to open the Block Parameters window.

  4. In the Main tab, check Schedule rates and set Schedule rates with to Ports.

  5. In the top-level model, add a Task Manager block.

  6. Click the Task Manager block and check the Use Schedule Editor ordering parameter.

  7. 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.

  8. 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.

Schedule Editor Top Level 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, PeriodicTaskn, with PeriodicTask2 and PeriodicTask3 sharing the same sample time.

Three timer-driven task model

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.

Scheduling in sequence with same priority

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.

Scheduling out of sequence with same priority

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

| | |