Real-Time Workshop User's Guide    

Run-Time Structure

The real-time program executes on the VxWorks target while Simulink and StethoScope execute on the same or different host workstations. Both Simulink and StethoScope require tasks on the VxWorks target to handle communication.

This diagram illustrates the structure of a VxWorks application using Simulink external mode and StethoScope.

Figure 12-2: The Run-Time Structure

The program creates VxWorks tasks to run on the real-time system: one communicates with Simulink, the others execute the model. StethoScope creates its own tasks to collect data.

Host Processes

There are two processes running on the host side that communicate with the real-time program:

VxWorks Tasks

You can run the real-time program in either singletasking or multitasking mode. The code for both modes is located in

The Real-Time Workshop compiles and links rt_main.c with the model code during the build process.

Singletasking.   By default, the model is run as one task, tSingleRate. This may actually provide the best performance (highest base sample rate) depending on the model.

The tSingleRate task runs at the base rate of the model and executes all necessary code for the slower sample rates. Execution of the tSingleRate task is normally blocked by a call to the VxWorks semTake routine. When a clock interrupt occurs, the interrupt service routine calls the semGive routine, which causes the semTake call to return. Once enabled, the tSingleRate task executes the model code for one time step. The loop then waits at the top by again calling semTake. For more information about the semTake and semGive routines, refer to the VxWorks Reference Manual. By default, it runs at a relatively high priority (30), which allows it to execute without interruption from background system activity.

Multitasking.   Optionally, the model can run as multiple tasks, one for each sample rate in the model:

Supporting Tasks..   If you select external mode and/or StethoScope during the build process, these tasks will also be created:


 Parameter Tuning and Monitoring Implementation Overview