Concurrent Execution on Simulink® Real-Time™

This example shows how to apply explicit partitioning to enhance concurrent execution of a real-time application that you generate by using Simulink Real-Time.

Simulink Real-Time supports concurrent execution by using implicit partitioning or explicit partitioning of models. For explicit partitioning, Simulink Real-Time users partition the root-level model by using referenced models, Simulink subsystems, or other options that Simulink supports. For more information about model partitioning for concurrent execution, see:

This example shows the relationship between the explicit partitioning of the tasks in the model subsystems and the execution of tasks by using the Simulink Real-Time profiling tool.

The example model dxpcmds6t runs at sample rate of 0.001 second.

To run the model with adjusted sample rate of 0.01 second, change the sample rated before running the example. In the MATLAB Command Window, type:

Ts = 0.01;

Open, Build, and Download the Model

Open the model dxpcmds6t. The model is mapped to seven threads: Model1_R1, Model1_R2, Model1_R3, Model1_R4, Model2_R1, Model2_R3, and Model2_R4.

These threads run at sample rates of Ts, 2*Ts, 3*Ts, 4*Ts, Ts, 3*Ts, and 4*Ts.


The explicit partitioning in the top-level model occurs in subsystems System1 and System2.



To apply explicit partitioning, in the Simulink Editor, on the Real-Time tab, click Hardware Settings, and then select Solver > Configure Tasks. Select the Tasks and Mapping node.

Build, download, and run the model.

tg = slrt('TargetPC1');
### Starting Simulink Real-Time build procedure for model: dxpcmds6t
### Generated code for 'dxpcmds6t' is up to date because no structural, parameter or code replacement library changes were found.
### Successful completion of build procedure for model: dxpcmds6t
### Created MLDATX ..\dxpcmds6t.mldatx

Display Profiling Data

The profiling data shows the execution time of each thread on a multi-core target computer

profData = tg.getProfilerData;
Processing data, please wait ...

Close the Model