| Real-Time Workshop® Embedded Coder™ | ![]() |
| On this page… |
|---|
The Real-Time Workshop Embedded Coder product provides a Wind River Systems VxWorks example main program as a template for the deployment of generated code in a real-time operating system (RTOS) environment. You should read the preceding sections of this chapter as a prerequisite to working with the VxWorks example main program. An understanding of the Real-Time Workshop Embedded Coder scheduling and tasking concepts and algorithms, described in Stand-Alone Program Execution, is essential to understanding how generated code is adapted to an RTOS.
In addition, an understanding of how tasks are managed under the VxWorks RTOS is required. See your VxWorks documentation.
To generate a VxWorks example program:
In the Custom templates subpane of the Real-Time Workshop/Templates pane of the Configuration Parameters dialog box, select the Generate an example main program option (this option is on by default).
When Generate an example main program is selected, the Target operating system pop-up menu is enabled. Select VxWorksExample from this menu.
Some modifications to the generated code are required; comments in the generated code identify the required modifications.
In a VxWorks example program, the main program and the base rate and sub-rate tasks (if any) run as prioritized tasks. The logic of a VxWorks example program parallels that of a stand-alone program; the main difference lies in the fact that base rate and sub-rate tasks are activated by clock semaphores managed by the operating system, rather than directly by timer interrupts.
Your application code must spawn model_main() as an independent VxWorks task. The task priority you specify is passed in to model_main().
As with a stand-alone program, the VxWorks example program architecture is tailored to the number of rates in the model and to the solver mode (see Permitted Solver Modes for Real-Time Workshop Embedded Coder Targeted Models). The following sections discuss each possible case.
In a single-rate, singletasking model, model_main() spawns a base rate task, tBaseRate. In this case tBaseRate is the functional equivalent to rtOneStep. The base rate task is activated by a clock semaphore provided by the VxWorks RTOS, rather than by a timer interrupt. On each activation, tBaseRate calls model_step.
Note that the clock rate granted by the VxWorks RTOS may not be the same as the rate requested by model_main.
In a multirate, multitasking model, model_main() spawns a base rate task and sub-rate tasks. Task priorities are assigned by rate.
As in a stand-alone program, rate grouping code is used (where possible) for multirate, multitasking models. The base rate task calls model_step0, while the sub-rate tasks call model_stepN. The base rate task calls a function that updates flags—an active task flag for each subrate and rate transition flags for tasks that exchange data. This function assumes the use of a rate-monotonic scheduler.
In a multirate, singletasking model, model_main() spawns only a base rate task, tBaseRate. All rates run under this task. The base rate task is activated by a clock semaphore provided by the VxWorks RTOS, rather than by a timer interrupt. On each activation, tBaseRate calls model_step.
model_step in turn calls the rate_scheduler utility, which maintains the scheduling counters that determine which rates should execute. model_step is responsible for checking the counters.
![]() | Stand-Alone Program Execution | Model Entry Points | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |