Task Manager
Create and manage task executions in Simulink model
Libraries:
SoC Blockset /
Processor Task Execution
C2000 Microcontroller Blockset /
Scheduling
Embedded Coder Support Package for Infineon AURIX TC3x Microcontrollers /
Scheduling
Embedded Coder Support Package for Infineon AURIX TC4x Microcontrollers /
Scheduling
Description
The Task Manager block simulates the execution of software tasks as they would be expected to behave on an SoC processor. With the Task Manager, you can add and remove tasks from your model that can either be timer-driven or event-driven. Tasks can be represented in a model as rates, for timer-driven tasks, or function-call subsystems, for event-driven tasks, contained inside a single Model block. The Task Manager executes individual tasks based on their parameters, such as period, duration, trigger, priority, or processor core, and the combination of that task with the state of other tasks and their priorities in the running model.
In simulation, this block uses code generation to improve simulation speed. This entails some overhead when first simulating, but subsequent simulations are faster if the block settings remain unchanged. For more information, see Interpreted Execution vs. Code Generation.
Note
The Task Manager block cannot be used in a referenced model. For more information on referenced models, see Model block.
The Task Manager block provides three methods to specify the duration of a task in simulation:
A probability model of task duration defined in the block mask.
From a data file recording of either a previous task simulation or from a task on an SoC device.
Input ports on the block, which you can connect to more dynamic models of task duration.
Examples
Timer-Driven Task
Use the Task Manager block in a simple system where a timer-driven task samples and modifies data generated from a random number source.
(SoC Blockset)
Event-Driven Task
Use the task manager block to a simple system where data from UDP source gets processed asynchronously each time a data packet arrives. The task manager block
(SoC Blockset)
Task Execution
Simulate task execution and how to generate code and run it on an SoC hardware board.
(SoC Blockset)
Limitations
A model containing a Task Manager blocks does not support simulation stepping. For more information on simulation stepping, see Debug Simulations in the Simulink Editor.
Ports
Output
Task1
— Function-call from Task1
scalar
A function-call signal that can trigger timer-driven and event-driven tasks, represented as rate or function-call subsystems in the processor Model block, respectively.
For a rate port from a timer-driven subsystem, to show on the Model block, set the Block Parameters > Main > Schedule rates and select ports. For a function-call port from an event-driven subsystem contained in a Function-Call Subsystem block to show on the Model block, include an Inport in the processor Model block connected to the function-call trigger port of the subsystem. In the Inport, check Block Parameters > Signal Attributes > Output function call.
Note
The Task1
port must be connected to either a
function-call port or scheduled rate signal port on a
Model block.
Dependencies
To create or remove a control signal port for a task, add or remove the task from the Task Manager block by clicking the Add or Delete buttons in the block dialog mask.
Input
Task1
Event — Message event notification
scalar
A message port that triggers the
associated event-driven task. The Task1Event
port receives the message from Event Source block. For more
information on messages, see Messages.
Dependencies
To show a
port, then Task1
Event
must
have Type set to
Task1
Event-driven
.
Data Types: rteEvent
Task1
Dur — Task duration
positive scalar
A positive value signal that specifies the execution duration of a task at the present time. For more information on specifying task duration, see Task Duration (SoC Blockset).
Dependencies
To enable this port, set the Specify task duration
via parameter to Input
port
.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
Parameters
Enable task simulation — Enable simulation of task duration
on
(default) | off
Enable or disable the simulation of task duration. If you clear this parameter, tasks simulate using a function-call generator inheriting their period from the fundamental sample time of the model for event-driven tasks or from the dialog for timer-driven tasks.
List of tasks — List of tasks
Task1
(default)
List of the tasks generated by the Task Manager block. Each task has a set of parameters listed in the Main and Simulation tabs of the block dialog mask.
Add — Add task
button
Add a task to the Task Manager block. During deployment, each task is encapsulated as an execution thread in the generated code. The properties of the thread are taken from the Main parameters for that task. During simulation, the task uses a combination of the Main and Simulation parameters for that task.
Delete — Delete existing task
button
Remove a task from the Task Manager.
Dependencies
To enable this parameter, specify at least two tasks.
Use Schedule Editor ordering — Specify task priority using Schedule Editor tool
off
(default) | on
Use the Schedule Editor to specify the ordering of the tasks in the SoC model. When using the Schedule Editor, task priority is automatically assigned to the tasks based on their order in the editor and the base rate priority of the processor model.
Main
Name — Name of task
Task1
(default) | character vector
Unique name of the task. The task name must only contain alphanumeric characters and underscores.
Type — Trigger type of task
Timer-driven
(default) | Event-driven
Specify the task as timer-driven or event-driven. For more information on timer- and event-driven tasks, see Timer-Driven Task (SoC Blockset) and Event-Driven Tasks (SoC Blockset), respectively.
Dependencies
To enable this parameter, set Type
to
Timer-driven
.
Period — Timer period
0.1
(default) | positive scalar
Specify the trigger time period for timer-driven tasks.
Core — Processor core to execute task
0
(default) | non-negative integer | -1
Specify the number of the processor core where a task executes. .
To have the operating system dynamically assign a core to the task,
set this value to -1
.
Priority — Priority of task in scheduler
10
(default) | positive integer
Specify the schedulers priority for the event-driven task between
1
and 99
. Higher priority
tasks can preempt lower priority tasks, and vice versa. The task
priority range is limited by the hardware attributes. For more
information on task priority, see Task Priority and Preemption (SoC Blockset).
Dependencies
To enable this parameter, set Type
to
Event-driven
and Use
Schedule Editor ordering
to
off
.
Drop tasks that overrun — Drop tasks that overrun
off
(default) | on
Select this parameter to force tasks to drop, rather than catch up, following an overrun instance. For more information on task overruns, see Task Overruns and Countermeasures (SoC Blockset).
Note
No more than 2 instances of a task can overrun execution when
Drop tasks that overrun
is set to
off
. Any additional task instances that
overrun drop automatically.
Simulation
Play recorded task execution sequence — Enable playback from file
off (default) | on
Select this parameter for the Task Manager block to play back the recorded execution data provided from the specified File name parameter. For more information on replaying task execution, see Task Execution Playback Using Recorded Data (SoC Blockset).
Specify task duration via — Source of task execution time
Dialog
(default) | Input port
| Record task execution statistics
Specify the source of the timing information for the task execution.
Dialog
- Use a normally distributed probabilistic model with Mean, Deviation, Min, and Max defined in the block dialog mask.Input port
– When set from Input port, the block input port dynamically defines the execution duration.Record task execution statistics
– Use a normally distributed probabilistic model with mean and deviation provided in file specified by File name.
For more information on configuring task duration, see Task Duration (SoC Blockset).
Add — Adds distribution
button
Adds a distribution to the set of normal distributions that generates an execution duration.
Note
Only a maximum five distributions can be assigned to a single task.
Delete — Remove distribution
button
Remove a distribution from the set of normal distributions.
Percent — Likelihood of distribution
100
(default) | positive scalar
Specify the likelihood of each normal distribution. The Percent weighted sum of normal distributions determines the task duration likelihood.
Note
The sum of Percent for all the distributions
in a single task must equal 100
.
Mean — Mean task duration in simulation
1e-06
(default) | positive scalar
Specify the mean duration of the task during simulation of the task. The simulated task duration uses a normal distribution with a specified Mean and SD parameter values as a first-order approximation of the task behavior.
SD — Standard deviation of task duration in simulation
0
(default) | positive scalar
Specify the standard deviation duration of the task during simulation of the task. The simulated task duration uses a normal distribution with a specified Mean and SD as a first-order approximation of the task behavior.
Min — Lower limit of task duration
1e-06
(default) | positive scalar
Lower limit of a task duration distribution.
Max — Upper limit of task duration
1e-06
(default) | positive scalar
Upper limit of a task duration distribution.
File name — File containing diagnostic scheduling data
filepath
The data in this file specifies the Mean and SD parameter values. When the Play recorded task execution sequence parameter is selected, the specified CSV file provides the explicit task execution timing. The CSV file contains the diagnostic data of the task scheduler previously recorded from the hardware board.
Dependencies
To enable this parameter, set the Specify task duration
via parameter to Recorded task execution
statistics
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
To automatically generate C code for your design, and execute on an SoC device, use the SoC Builder tool. To generate and execute C code for your SoC models, Embedded Coder® features are required. For more information on generating code for SoC designs, see Use SoC Builder to Generate SoC Design (SoC Blockset).
The tasks in the Task Manager block execute as threads in the generated code. The task parameters in the Task Manager block specify the priority and execution core of the thread.
Version History
Introduced in R2019a
See Also
IO Data Source (SoC Blockset) | Memory Channel (SoC Blockset)
Topics
- What is Task Execution? (SoC Blockset)
- Task Duration (SoC Blockset)
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)