Abstract
The VxWorks Task Block is a function-call subsystem which spawns, as a
VxWorks task, the function-call subsystem connected to its output. It is
meant to be placed between 2 other function-call subsytems. Typically it
would be placed between the VxWorks Interrupt Block and a function-call
subsystem block or a Stateflow chart. Another example would be to place
the Task Block at the output of a Stateflow Diagram which has an Event
"Output to Simulink" configured as a function-call.
The VxWorks Task Block performs the following functions:
- The function-call subsystem connected to its output is spawned as a
task using the VxWorks system call taskSpawn(). (The task is deleted using
taskDelete() during model termination.)
- Code is added to this spawned function-call subsystem to wrap it in a
infinite while loop.
- A semaphore is created which is used to communicate between the Task
Block and the function-call subsystem connected to its output.
- Code is added to the top of the infinite while loop of the spawned task
to wait on a the semaphore, using semTake(). semTake() is first called
with NO_WAIT specified. This allows the task to determined if second
semGive() had occured before the function-call subsystem completed. This
would indicate the interrupt rate is too fast or the Task Priority is too
low.
- Code is generated for the Task Blocks own function call subsystem which
simply calls semGive(), this allows the output function-call subsystem to
run. As an example, if the Task Block was placed at the output of a
VxWorks Interrupt Block, the semGive would occur inside a Interrupt Service
Routine(ISR).
Task Name
Optional name, which if provided, is used as the first argument to the
taskSpawn() system call. This name is used by VxWork routines to identify the
task they are called from to aid in debugging.
Task Priority
The Task Priority is the VxWorks priority that the function-call subsystem
task is given when it is spawned. The priority is can be a very important
consideration in relation to other tasks priorities in the VxWorks system.
In particular, the default priority of the model code is 30 and, when
multitasking is enabled, the priority of the each subrate task increases by
one from the default model base rate. Other task priorities in the system
should also be considered when choosing a Task Priority. VxWorks
priorities range from 0 to 255 where a lower number is a higher priority.
Stack Size
The function-call subsystem is spawned with the stack size specified. This
is maximum size that the tasks stack can grow to. The value should be
chosen based on the number of local variables in the task.