Main Content

Run external mode in a background thread

Execution of external mode task in generated code within background thread

Model Configuration Pane: Hardware Implementation / Simulink or Embedded Coder Hardware Support Package / Hardware board settings / Target hardware resources / External mode

Description

The Run external mode in a background thread parameter forces background-thread execution of the external mode task in the generated code.

When external mode runs in the model thread, external mode executes after each execution step of the model and collects data at the base rate of the model. When model code consumes most of the thread execution time in each time step, external mode execution overruns into the next time step. This overrun delays the start of the next model execution step and degrades the real-time behavior of the deployed model.

You can configure external mode to run in a background thread. When external mode runs in a background thread, it executes in the time between the end of model code of one time step and the start of the next time step. By not blocking the model step, external mode can be used in systems that require real-time execution. This configuration enables direct observation of the deployed model on the hardware board as it would behave in standalone operation. This diagram shows the execution timing of external mode running in the foreground and background threads.

When external mode runs in a background thread, it executes in the time between the end of model code of one time step and the start of the next time step.

When model code consumes most of the execution time for each time step, external mode in the background thread starves for execution time. Without sufficient time to collect and transmit data from the hardware board to the host computer, data packets drop. This case results in gaps in the data logging.

To help avoid dropped data packets in deployed models where real-time execution takes priority over data logging, configure external mode to operate as a background task.

Dependencies

None

Settings

on (default) | off

Enabling the Run external mode in a background thread parameter is not recommended for models that use a very small time step or that might encounter task overruns. These situations can cause Simulink® to become unresponsive.

Examples

expand all

  1. In the Simulink Editor, select Simulation > Model Configuration Parameters.

  2. In the Configuration Parameters dialog box, click Hardware Implementation.

  3. Set the Hardware board parameter to either:

    • Xilinx Zynq ZC702 evaluation kit

    • Xilinx Zynq ZC706 evaluation kit

    • ZedBoard

    Then, click Apply.

    The parameter values under Hardware board settings are automatically populated to their default values.

  4. If you chose Xilinx Zynq ZC706 evaluation kit or ZedBoard, set the Feature set for selected hardware board to Simulink or Embedded Coder Hardware Support Package and click Apply.

  5. From the External mode group, select a Run external mode in a background thread from the drop down list and click Apply.

  6. Click OK to close the dialog box.

Recommended Settings

No recommendation.

Programmatic Use

No programmatic use is available.

Version History

Introduced in R2014b