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. 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
slrt_ex_mds_and_tasks 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;
The explicit partitioning in the top-level model occurs in subsystem1.
The explicit partitioning in the top-level model occurs in subsystem2.
Open the model
slrt_ex_mds_and_tasks. The model is mapped to seven threads:
These threads run at sample rates of
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.
set_param(mdl,'RTWVerbose','off'); slbuild(mdl); tg = slrealtime; load(tg,mdl); % Open TET Monitor slrtTETMonitor; % Start profiler on the target computer startProfiler(tg); start(tg); pause(2); stop(tg);
### Starting serial model reference simulation build ### Starting serial model reference code generation build ### Model reference code generation target for slrt_ex_mds_subsystem1 is up to date. ### Model reference code generation target for slrt_ex_mds_subsystem2 is up to date. ### Generated code for 'slrt_ex_mds_and_tasks' is up to date because no structural, parameter or code replacement library changes were found. ### Successful completion of build procedure for: slrt_ex_mds_and_tasks ### Created MLDATX ..\slrt_ex_mds_and_tasks.mldatx Build Summary 0 of 3 models built (3 models already up to date) Build duration: 0h 0m 11.164s
The profiling data shows the execution time of each thread on a multi-core target computer.
profData = tg.getProfilerData; profData.plot;
Processing data on target computer ... Transferring data from target computer ... Warning: Unrecognized function or variable 'CloneDetectionUI.internal.CloneDetectionPerspective.register'. Processing data on host computer ...