Customize Concurrent Execution Settings

You can configure the concurrency settings of your target architecture by creating a different number of tasks or setting data transfer parameters.

Configuring Data Transfer Communications

Use the Data Transfer Options pane to define communications between tasks. The settings you make here are the values used for the Use global setting option of the Data Transfer tab of the Signal Properties dialog box. You can also override these options for each signal from the Data Transfer pane of the Signal Properties dialog box.

Data Transfer Options

Data Transfer TypeSimulationDeployment
Ensure data integrity only.Data transfer is simulated using a one-step delay. Simulink® Coder™ ensures data integrity during data transfer. Simulink generates code to operate with maximum responsiveness and data integrity. However, the implementation is interruptible, which can lead to loss of data during data transfer.
Ensure deterministic transfer (maximum delay).Data transfer is simulated using a one-step delay.Simulink Coder ensures data integrity during data transfer. In addition, Simulink Coder ensures data transfer is identical with simulation.
Ensure deterministic transfer (minimum delay).Data transfer occurs within the same step.

  • For continuous signals, Simulink uses extrapolation methods to compensate for numerical errors that were introduced due to delays and discontinuities in data transfer.

  • For signals that are configured for Ensure Data Integrity Only and Ensure deterministic transfer (maximum delay) data transfers, you might need to provide an initial condition to avoid numerical errors. You can specify this initial condition in the Data Transfer tab of the Signal Properties dialog box. To access this dialog box, right-click the signal line and select Properties from the context menu. A dialog box like the following is displayed.

    1. From the Data Transfer Options table, determine how you want your tasks to communicate.

    2. In the Concurrent Execution dialog box, select Data Transfer defaults and apply the settings from step 1.

    3. Apply your changes.

Select Target Architecture

  1. In the Concurrent Execution dialog box, in the Concurrent Execution pane, click Select. The concurrent execution target architecture selector appears.

  2. Select your target.

    PropertyDescription

    Multicore

    Single CPU with multiple cores.

    Sample Architecture

    Single CPU with multiple cores and two FPGAs.

    Simulink Real-Time

    Simulink Real-Time™ target.

    Get more ...

    Click OK to start the Support Package Installer. From the list, select the target and follow the instructions.

  3. In the Target architecture window, clear the Preserve compatible properties check box to reset existing target property settings to their default. Alternatively, select the Preserve compatible properties check box to preserve existing target property settings.

  4. Click OK.

    Simulink adds the corresponding software and hardware nodes to the configuration tree hierarchy. For example, the following illustrates one software node and two hardware nodes added to the configuration tree when you select Sample architecture as the target architecture.

Configuring Periodic Triggers and Tasks

If you want to explore the effects of increasing the concurrency on your model execution, you can create additional periodic tasks in your model.

  1. In the Concurrent Execution dialog box, right-click on the Periodic node and select Add task.

    A task node appears in the Configuration Execution hierarchy.

  2. Select the task node and enter a name and period for the task, then click Apply.

    The task node is renamed to the name you enter.

  3. Optionally, specify a color for the task. The color illustrates the block-to-task mapping. If you do not assign a color, Simulink chooses a default color. If you enable sample time colors for your model, the software honors the setting.

  4. Click Apply as necessary.

To create more periodic triggers, click the Add periodic trigger symbol. You can also create multiple periodic triggers with their own trigger sources.

    Note:   Periodic triggers let you represent multiple periodic interrupt sources such as multiple timers. The periodicity of the trigger is either the base rate of the tasks that the trigger schedules, or the period of the trigger. Data transfers between triggers can only be Ensure Data Integrity Only types. With blocks mapped to periodic triggers, you can only generate code for ert.tlc and grt.tlc system target files.

When the periodic tasks and trigger configurations are complete, configure the aperiodic (interrupt) tasks as necessary. If you do not need aperiodic tasks, continue to Map Blocks to Tasks, Triggers, and Nodes.

Configuring Aperiodic Triggers and Tasks

  1. To create an aperiodic trigger, in the Concurrent Execution dialog box, right-click the Concurrent Execution node and click the Add aperiodic trigger symbol.

    A node named InterruptN appears in the configuration tree hierarchy.

  2. Select Interrupt.

    This node represents an aperiodic trigger for your system.

  3. Specify the name of the trigger and configure the aperiodic trigger source. Depending on your deployment target, choose either Posix Signal (Linux/VxWorks 6.x) or Event (Windows). For POSIX® signals, specify the signal number to use for delivering the aperiodic event. For Windows® events, specify the name of the event.

  4. Click Apply.

The software services aperiodic triggers as soon as possible. If you want to process the trigger response using a task:

  1. Right-click the Interrupt node and select Add task.

    A new task node appears under the Interrupt node.

  2. Specify the name of the new task node.

  3. Optionally, specify a color for the task. The color illustrates the block-to-task mapping. If you do not assign a color, Simulink chooses a default color.

  4. Click Apply.

You can delete tasks (both periodic and aperiodic) as well as triggers by right-clicking them in the pane and selecting Delete.

When the aperiodic tasks are complete, continue to Map Blocks to Tasks, Triggers, and Nodes.

Map Blocks to Tasks, Triggers, and Nodes

After you specify the target architecture and create tasks and triggers, you can explicitly assign partitions to these execution elements.

  1. In the Concurrent Execution dialog box, click the Tasks and Mapping node.

    The Tasks and Mapping pane appears. If you added a new Model block to your model, the new block appears in the table with a select task entry under it.

  2. If you want to add a new task to a block, in the Name column, right-click a task under the block and select Add new entry.

  3. To assign a task for the entry, click the box in the Name column and select an entry from the list. For example:

    The block-to-task mapping symbol appears on the top-left corner of the Model block. For example:

    If you assign a Model block to multiple tasks, multiple task symbols are displayed in the top-left corner.

    To display the Concurrent Execution dialog box from the block, click the block-to-task mapping symbol.

  4. Click Apply.

Note the following:

  • System tasks allow you to incrementally perform the mapping process. This means that if there is only one periodic trigger, Simulink assigns any Model block partitions or MATLAB System blocks, that you have not explicitly mapped to a task, trigger, or hardware node, to a task created by the system. Simulink creates at most one system task for each rate in the model. If there are multiple periodic triggers created, you must explicitly map the Model block partitions or MATLAB System blocks to a task, trigger or hardware node.

  • You must map Model block partitions that contain continuous blocks to the same periodic trigger.

  • You can map only Model blocks to hardware nodes. Additionally, if you map the Model block to a hardware node, and the Model block contains multiple periodic sample times, you must clear the Allow tasks to execute concurrently on target check box in the Solver pane of the Configuration Parameters dialog box.

When the mapping is complete, simulate the model again. See Interpret Simulation Results .

Was this topic helpful?