OS Integration
The ARXF-CP has been adapted to AUTOSAR compatible Operating System.
Message Queues
The AUTOSAR OS supports no message queue, but the ARXF-CP uses an event queue per task which operates as a FIFO mechanism.
Events are allocated in the static memory pools, allocated per SW-C instance. When one object sends a UML event to another object,
only the pointer to the event is sent. Moreover, the message queue is implemented as a head and a tail pointer; it can grow
dynamically and is not allocated as such.
For each active class, an OS task is used.
All sequential classes run in the so-called swc task. See Concurrency
Task details including stack and priority are specified in an AUTOSAR tool as part of the Basic Software or BSW. OS tasks are configured statically:
tasks are not created at runtime when an active class is created.
The properties CG::Class::ActiveMessageQueueSize and CG::Class::ActiveStackSize are not used in ARXF_CP_V8.0.1.
By default, the ARXF-CP uses the AUTOSAR mechanism
of an exclusive area for critical region handlers: the RTE will generate a entry- and exit function for each exclusive area defined.
An exclusive area must be specified at the AUTOSAR level per SWC. Code generation for composing RTE function pointers require:
- the stereotype CpExclusiveArea on the exclusive area attribute of an SWC
- an exclusiveAreaAccess stereotyped dependency between a runnable and this exclusive area. See Profiles.
The enter- and exit functions are generated by the RTE: within the RTE configuration it is defined which interrupts are blocked:
this is ALL_INTERRUPT_BLOCKING or OS_INTERRUPT_BLOCKING, but also the BSW scheduler configuration and OS task types are of influence.
The ARXF-CP requires at least three exclusive areas:
- one for manipulating the static allocated memory pools
This list is maintained globally per SW-C instance or prototype.
- one for manipulating the static allocated timer list
This list is maintained globally per SW-C instance or prototype.
- one for manipulating the static allocated event list for the swc task
This list is maintained globally per SW-C instance or prototype.
- one for manipulating the static allocated event list for each active class.
This list is maintained globally per SW-C instance or prototype where the class is part of.
When the ARXF-CP is initialized, usually at SW-C initialization time, a call to
RXF_SWC_Init() is performed, passing the function pointers to the RTE generated entry- and exit functions as arguments.
It is possible to safeguard critical regions yourselves:
- at the AUTOSAR level, an exclusive area must be configured.
The RTE will generate a contract for your SW-C: this will be Rte_<swc>.h
- at the Rhapsody level, you will see such exclusive area when you import ArXML with the Software Component Description
- the RTE will generate an entry- and exit function for that exclusive area, which act like a critical region handler.
You can also use the properties to specify your own critical region handler.
This is done via properties set on the Code Generation tab of the ARXF-CP Configuration.
The ARXF-CP does not set any timer, but it does need a regular heartbeat. In the Getting Started examples, the
runnable <swc>_eventDispatcherSwc is used, which is called by the RTE every 10 msec.
The timer granularity must match the value of RXF_MS_PER_TICK, see List of Defines
The ARXF-CP uses a global counter which is local per SW-C instance. This counter needs to be incremented.
The resolution determines the timeouts you can effectively specify in your model: if the runnable is called every 100 msec,
specifying tm(10) makes no sense..
See Realtime behavior for further details.
sample code snippet taken from a <swc>_eventDispatcherSwc:
Explanation:
- first, a pointer to an ARXF-CP task pointer is retrieved.
For this, the task pointer to that object has been stored during initialization of the SW-C into an inter-runnable,
for which the RTE has generated a setter and getter.
- we test if this is a NULL pointer (the RTE has not stored yet our task pointer) or our SWC instance has not been initialized yet: <swc>_init() has not been called yet.
- the task pointer points to an ARXF-CP SWC structure or actually instance
- the timer ticks for this SW-C instance is incremented.
- the UML event queue is processed. The function RXF_Active_execute() returns when there are no more events in the queue or a maximum number has been processed.