Documentation Center

  • Trial Software
  • Product Updates

Concurrent Execution with Simulink® Real-Time™

This example shows how to perform concurrent execution of a model on Simulink Real-Time. It displays the execution of each model thread using the Simulink Real-Time profiling tool.

dxpcmdsdemo runs the model with the default sample time 0.001 second.

To run the model with adjusted sample time nnn second, please type Ts = nnn before dxpcmdsdemo. For example:

Ts = 0.01;

dxpcmdsdemo;

Requirements

  1. Boot the target computer with the Simulink Real-Time real-time kernel.

  2. At the MATLAB® command prompt, type dxpcmdsdemo to download and run the model on the target computer.

Select and Open the Model

Open the model dxpcmds6tdxpcmds6t (see Figure 1). The model is mapped to 7 threads (Model1_R1, Model1_R2, Model1_R3, Model1_R4, Model2_R1, Model2_R3, and Model2_R4) running at sample times of Ts, 2*Ts, 3*Ts, 4*Ts, Ts, 3*Ts and 4*Ts respectively.

mdl='dxpcmds6t';
open_system(mdl);

Figure 1: A Model Comprised of Seven Tasks

Details in Model1

open_system([mdl, '/Model1']);

Figure 2: Four Tasks in Model1

Details in Model2

open_system([mdl, '/Model2']);

Figure 3: Three Tasks in Model2

Build, Download, and Run the Model

slrtpingtarget;
set_param(mdl,'RTWVerbose','off');
rtwbuild(mdl);
tg = slrt;
tg.load(mdl);
tg.start;
pause(2);
tg.stop;

Display Profiling Data

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

profileInfo.modelname = 'dxpcmds6t.mdl';
profileInfo.noreport = 0;
profile_xpc(profileInfo);
Copying data from target machine, please wait ...
Processing data, please wait ...
 

Figure 5: Plot of Recorded Profiling Data

Close the Model

close_system(mdl,0);
close_system('dxpcmds_ref1',0);
close_system('dxpcmds_ref2',0);
Was this topic helpful?