Autosar SWS Os
Autosar SWS Os
Autosar SWS Os
Disclaimer
This work (specification and/or software implementation) and the material contained
in it, as released by AUTOSAR, is for the purpose of information only. AUTOSAR
and the companies that have contributed to it shall not be liable for any use of the
work.
The material contained in this work is protected by copyright and other types of
intellectual property rights. The commercial exploitation of the material contained in
this work requires a license to such intellectual property rights.
This work may be utilized or reproduced without any modification, in any form or by
any means, for informational purposes only. For any other purpose, no part of the
work may be utilized or reproduced, in any form or by any means, without permission
in writing from the publisher.
The work has been developed for automotive applications only. It has neither been
developed, nor tested for non-automotive applications.
The word AUTOSAR and the AUTOSAR logo are registered trademarks.
Table of Content
1 Introduction and functional overview ................................................................. 11
This feature set defines the type of OS commonly used in the current generation of
automotive ECUs, with the exception of Telematic/Infotainment systems. It is
assumed that Telematic/Infotainment systems will continue to use proprietary Oss
under the AUTOSAR framework (e.g. Windows CE, VxWorks, QNX, etc.). In the case
where AUTOSAR components are needed to run on these proprietary Oss, the
interfaces defined in this document should be provided as an Operating System
Abstraction Layer (OSAL).
This document uses the industry standard [15] (ISO 17356-3) as the basis for the
AUTOSAR OS. The reader should be familiar with this standard before reading this
document.
Term: Definition
Access Right An indication that an object (e.g. Task, ISR, hook function) of an OS-Application
has the permission of access or manipulation with respect to memory, OS
services or (set of) OS objects.
Cardinality The number of items in a set.
Counter An operating system object that registers a count in ticks. There are two types of
counters:
Hardware Counter A counter that is advanced by hardware (e.g. timer).
The count value is maintained by the peripheral “in
hardware”.
Software Counter A counter which is incremented by making the
IncrementCounter() API call (see
SWS_Os_00399). The count value is maintained by
the operating system “in software”.
Deadline The time at which a Task/Category 2 ISR must reach a certain point during its
execution defined by system design relative to the stimulus that triggered
activation. See Figure 2.1
Delay The number of ticks between two adjacent expiry points on a schedule table.
12 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
ISRs:
The net time from the first to the last instruction of the user provided
Category 2 interrupt handler excluding all preemptions due to higher
priority ISRs executing in preference.
Execution time includes the time spent in the error, pretask and posttask hooks
and the time spent making OS service calls.
Execution Budget Maximum permitted execution time for a Task/ISR.
Expiry Point The offset on a Schedule Table, measured from zero, at which the OS activates
tasks and/or sets events.
Initial Expiry Point The expiry point with the smallest offset
Final Expiry Point The expiry point with the largest offset
Hook Function A Hook function is implemented by the user and invoked by the operating system
in the case of certain incidents. In order to react to these on system or application
level, there are two kinds of hook functions
Application-specific Hook functions within the scope of an individual OS-
Application.
System-specific Hook functions within the scope of the complete
system (in general provided by the integrator).
Initial Offset The smallest expiry point offset on a schedule table. This can be zero.
Interarrival Time Basic Tasks
The time between successively entering the READY state from the
SUSPENDED state. Activation of a task always represents a new arrival.
This applies in the case of multiple activations, even if an existing
instance of the task is in the RUNNING or READY state.
Extended Tasks:
The time between successively entering the READY state from the
SUSPENDED or WAITING states. Setting an event for a task in the
WAITING state represents a new arrival if the task is waiting on the
event. Waiting for an event in the RUNNING state which is already set
represents a new arrival.
ISRs:
The time between successive occurrences of an interrupt.
See Figure 2.1.
Interrupt Lock Time The time for which a Task/ISR executes with Category 1 interrupts
disabled/suspended and/or Category 2 interrupts disabled/suspended .
Interrupt Source The switch which enables a specific interrupt source in the hardware.
Enable
Interrupt Vector Conceptually, the interrupt vector table contains the mapping from hardware
Table interrupt requests to (software) interrupt service routines. The real content of the
Interrupt Vector Table is very hardware specific, e.g. it can contain the start
addresses of the interrupt service routines.
Final Delay The difference between the Final Expiry Point offset and the duration on a
schedule table in ticks. This value defines the delay from the Final Expiry Point to
the logical end of the schedule table for single-shot and “nexted” schedule tables.
Forced OS- The operating system frees all system objects, e.g. forcibly terminates Tasks,
Application disables interrupts, etc., which are associated to the OS-Application. OS-
Termination Application and internal variables are potentially left in an undefined state.
Forced The OS terminates the Task/Category 2 ISR and does ”unlock” its held
Termination resources. For details see SWS_Os_00108 and SWS_Os_00109.
Linker File File containing linking settings for the linker. The syntax of the linker file depends
on the specific linker and, consequently, definitions are stored “linker-specific” in
the linker file.
Lock Budget Maximum permitted Interrupt Lock Time or Resource Lock Time.
Master core A master core is a core from which the AUTOSAR system is bootstrapped.
Memory Protection A Memory Protection Unit (MPU) enables memory partitioning with individual
Unit protection attributes. This is distinct from a Memory Management Unit (MMU)
that provides a mapping between virtual addresses and physical memory
locations at runtime.
Note that some devices may realise the functionality of an MPU in an MMU.
Mode Describes the permissions available on a processor.
Privileged In general, in »privileged mode« unrestricted access is
available to memory as well as the underlying hardware.
Non-privileged In »non-privileged mode« access is restricted.
Modulus The number of ticks required to complete a full wrap of an OSEK counter. This is
equal to OsCounterMaxAllowedValue +1 ticks of the counter.
OS-Application A collection of OS objects
Trusted An OS-Application that may be executed in privileged mode and
may have unrestricted access to the API and hardware
resources. Only trusted applications can provide trusted
functions.
Non-trusted An OS-Application that is executed in non-privileged mode has
restricted access to the API and hardware resources.
OS object Object that belongs to a single OS-Application: Task, ISR, Alarm, Event,
Schedule Table, Resource, Trusted Function, Counter, Applicaton-specific hook.
OS Service OS services are the API of the operating system.
Protection Error Systematic error in the software of an OS-Application.
Memory access A protection error caused by access to an address in a
violation manner for which no access right exists.
Timing fault A protection error that violates the timing protection.
Illegal service A protection error that violates the service protection, e.g.
unauthorized call to OS service.
Hardware exception division by zero, illegal instruction etc.
Resource Lock The time an OSEK resource is held by a Task/ISR (excluding the preemptions of
Time the Task/ISR by higher prior Tasks/ISRs).
Response Time The time between a Task/ISR being made ready to execute and generating a
specified response. The time includes all preemptions. See Figure 2.1
Restart an OS- An OS-Application can be restarted after self-termination or being forcibly
Application terminated because of a protection error. When an OS-Application is restarted,
the OS activates the configured OsRestartTask.
Scalability Class The features of the OS (e.g. Memory Protection or Timing Protection), described
by this document, can be grouped together to customize the operating system to
the needs of the application. There are 4 defined groups of features which are
named scalability classes. For details see Chapter 7.11
Schedule Table Encapsulation of a statically defined set of expiry points.
Section Part of an object file in which instructions or data are combined to form a unit
(contiguous address space in memory allocated for data or code). A section in an
object file (object file format) has a name and a size.
From the linker perspective, two different sides can be distinguished:
Input section memory section in an input object file of the linker.
Output section memory section in an output object file of the linker.
Set (of OS objects) This document uses the term set, indicating a collection of the same type of OS
objects, in the strict mathematical sense, i.e.:
- a set contains zero or more OS objects (this means a set can be empty)
- the OS objects in the set are unique (this means there cannot be duplicate OS
objects in the set)
Spinlock A spinlock is a locking mechanism where the TASK waits in a loop ("spins")
repeatedly checking for a shared variable to become a certain value.
The value indicates whether the lock is free or not. In Multi-Core systems the
comparison and changing of the variable typically requires an atomic operation.
As the TASK remains active but is not doing anything useful, a spinlock is a busy
waiting mechanism
Spinlock variable A spinlock variable is a shared variable used by a spinlock to indicate whether a
spinlock is free or occupied.
Symbol Address label that can be imported/used by software modules and resolved by
the linker. The precise syntax of the labels is linker-specific. Here, these address
labels are used to identify the start and end of memory sections.
Start symbol Tags the start of a memory section
End symbol Tags the end of a memory section
Synchronization of Synchronization with a synchronization counter is achieved, if the expiry points of
schedule tables the schedule table are processed within an absolute deviation from the
with a synchronization counter that is smaller than or equal to a precision threshold.
synchronization
counter
Synchronization The “Synchronization Counter”, distinct from an OS counter object, is an external
Counter counter, external to the OS, against which expiry points of a schedule table are
synchronized
Task A Task is the object which executes (user) code and which is managed by the
OS. E.g. the OS switches between different Tasks (“schedules”). There are 2
types of Tasks; for more details see [15].
Basic Task A Task which can not block by itself. This means that it can not
wait for (OS) event(s).
Extended Task A Task which can block by itself and wait for (OS) event(s).
Time Frame The minmum inter-arrival time for a Task/ISR.
Trusted Function A service provided by a trusted OS-Application that can be used by other OS-
Applications (trusted or non-trusted).
Worst case The longest possible execution time.
execution time
(WCET)
Write access Storing a value in a register or memory location. All memory accesses that have
the consequence of writing (e.g. reads that have the side effect of writing to a
memory location) are treated as write accesses.
LOW’s Deadline
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
3 Related documentation
The ISO 17356 (“Road vehicles -- Open interface for embedded automotive
applications”) is a standard which was previously published by the OSEK/VDX
organization.
[15] ISO 17356-3: 2005: Road vehicles -- Open interface for embedded automotive
applications -- Part 3: OSEK/VDX Operating System (OS)
[16] ISO 17356-6:2006: Road vehicles -- Open interface for embedded automotive
applications -- Part 6: OSEK/VDX Implementation Language (OIL)
Thus, the specification SWS BSW General shall be considered as additional and
required specification for Operating System.
4.2 Terminology
The specification uses the following operators when requirements specify multiple
terms:
Where operators of the same precedence are used in the same sentence, commas
are used to disambiguate. The expression X AND Y, OR Z means (X AND Y) OR Z.
Runnables get access to hardware-sourced data through the AUTOSAR RTE. The
RTE provides the runtime interface between runnables and the basic software
modules. The basic software modules also comprise a number of tasks and ISRs
that are scheduled by the operating system.
It is assumed that the software component templates and the description of the basic
software modules provide sufficient information about the required runtime behavior
to be able to specify the attributes of tasks required to configure the OS.
3. The hardware supports atomic read and atomic write operations for a fixed
word length depending on the hardware.
5. The cores may have the same instruction set; at least a common basic
instruction set is available on all cores. Core specific add-ons may exist but
they are not taken into account.
6. The cores have the same data representation. For example, the same size of
integer, same byte and bit order, etc.
1
In this context “architecture” encompasses: the connections between cores and memory, and to peripherals and how interrupts
work.
20 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Shared RAM is available to all cores; at least all cores can share a substantial
part of the memory.
Flash shall be shared between all cores at least. However, performance can
be improved if Flash/RAM can be partitioned so that there are separate pathways
from cores to Flash.
A single address space is assumed, at least in the shared parts of the memory
address space.
4.6 Limitations
4.6.1 Hardware
The core AUTOSAR operating system assumes free access to hardware resources,
which are managed by the OS itself. This includes, but is not limited to, the following
hardware:
Specific (extended) features of the core operating system extend the requirements
on hardware resource. The following list outlines the features that have requirements
on the hardware. Systems that do not use these OS features do not have these
hardware requirements.
Time Protection: Timer Hardware for monitoring execution times and arrival rates.
In general hardware failures in the processor are not detected by the operating
system. In the event of hardware failure, correct operation of the OS cannot be
guaranteed.
The API of the operating system is defined as C function calls or macros. If other
languages are used they must adapt to the C interface.
4.6.3 Miscellaneous
The operating system does not provide services for dynamic memory management.
o It is assumed that the operating system may use timer units directly to drive
counters.
o If the user needs to drive scheduling directly from global time, then a global
time interrupt is required.
o If the user needs to synchronize the processing of a schedule table to a global
time, the operating system needs to be told the global time using the
SyncScheduleTable() service.
o The IOC described in this document provides communication between OS-
Applications. The IOC generation is based on configuration information which
is generated by the RTE generator. On the other hand the RTE uses functions
generated by the IOC to transmit data.
The code file structure of the Operating system module is not fixed, besides the
requirements in the General SRS.
OS
includes
Os.h
The figure above contains the defined AUTOSAR header file hierarchy of the
Operating System module.
The IOC generator generates an additional header file Ioc.h. Users of the Ioc.h shall
include the Ioc.h file. If an implementation of the IOC requires additional header files,
it is free to include them. The header files are self-contained, that means they will
include all other header files, which they require.
6 Requirements Traceability
This chapter contains references to requirements of other AUTOSAR documents.
cores
SRS_Os_80011 The number of cores that the SWS_Os_00583
operating system manages
shall be configurable offline
SRS_Os_80013 The behaviour of services shall SWS_Os_00569, SWS_Os_00589,
be identical to single core SWS_Os_00590, SWS_Os_00591,
systems SWS_Os_00592, SWS_Os_00593,
SWS_Os_00594, SWS_Os_00595,
SWS_Os_00607, SWS_Os_00618,
SWS_Os_00619, SWS_Os_00623,
SWS_Os_00629, SWS_Os_00630,
SWS_Os_00631, SWS_Os_00635,
SWS_Os_00636, SWS_Os_00637,
SWS_Os_00638, SWS_Os_00639,
SWS_Os_00640, SWS_Os_00643,
SWS_Os_00645, SWS_Os_00646,
SWS_Os_00647, SWS_Os_00663,
SWS_Os_00664, SWS_Os_00665
SRS_Os_80015 The MC extensions shall SWS_Os_00596, SWS_Os_00598,
provide a mechanism to SWS_Os_00599, SWS_Os_00600
activate tasks on different
cores
SRS_Os_80016 Event mechanism shall work SWS_Os_00602, SWS_Os_00604,
across cores SWS_Os_00605
SRS_Os_80018 A method to synchronize tasks SWS_Os_00632, SWS_Os_00633,
on more than one core shall be SWS_Os_00634, SWS_Os_00641,
provided SWS_Os_00642, SWS_Os_00644,
SWS_Os_00648, SWS_Os_00649,
SWS_Os_00650, SWS_Os_00652,
SWS_Os_00653, SWS_Os_00654,
SWS_Os_00655, SWS_Os_00656,
SWS_Os_00657, SWS_Os_00658,
SWS_Os_00659, SWS_Os_00660,
SWS_Os_00661
SRS_Os_80020 A data exchange mechanism SWS_Os_00611, SWS_Os_00671,
shall be provided SWS_Os_00718, SWS_Os_00719,
SWS_Os_00720, SWS_Os_00721,
SWS_Os_00722, SWS_Os_00723,
SWS_Os_00724, SWS_Os_00725,
SWS_Os_00726, SWS_Os_00727,
SWS_Os_00728, SWS_Os_00729,
SWS_Os_00730, SWS_Os_00731,
SWS_Os_00732, SWS_Os_00733,
SWS_Os_00734, SWS_Os_00735,
SWS_Os_00736, SWS_Os_00737,
SWS_Os_00738, SWS_Os_00739,
SWS_Os_00740, SWS_Os_00741,
SWS_Os_00742, SWS_Os_00743,
SWS_Os_00744, SWS_Os_00745,
SWS_Os_00746, SWS_Os_00747,
SWS_Os_00748, SWS_Os_00749,
SWS_Os_00750, SWS_Os_00751,
SWS_Os_00752, SWS_Os_00753,
SWS_Os_00754, SWS_Os_00755,
SWS_Os_00756, SWS_Os_00757,
SWS_Os_00758, SWS_Os_00759,
SWS_Os_00760, SWS_Os_00761,
SWS_Os_00803, SWS_Os_00805
SRS_Os_80021 The MC extension of the SWS_Os_00612, SWS_Os_00613,
AUTOSAR environment shall SWS_Os_00614, SWS_Os_00615,
support a mutual exclusion SWS_Os_00620, SWS_Os_00622,
mechanism between cores SWS_Os_00624, SWS_Os_00648,
that shall not cause deadlocks SWS_Os_00649, SWS_Os_00650,
SWS_Os_00651, SWS_Os_00652,
SWS_Os_00653, SWS_Os_00654,
SWS_Os_00655, SWS_Os_00656,
SWS_Os_00657, SWS_Os_00658,
SWS_Os_00659, SWS_Os_00660,
SWS_Os_00661, SWS_Os_00666,
SWS_Os_00686, SWS_Os_00687,
SWS_Os_00688, SWS_Os_00689,
SWS_Os_00690, SWS_Os_00691,
SWS_Os_00692, SWS_Os_00693,
SWS_Os_00694, SWS_Os_00695,
SWS_Os_00696, SWS_Os_00697,
SWS_Os_00698, SWS_Os_00699,
SWS_Os_00700, SWS_Os_00701,
SWS_Os_00703, SWS_Os_00704,
SWS_Os_00705, SWS_Os_00706,
SWS_Os_00707, SWS_Os_00708,
SWS_Os_00709, SWS_Os_00710,
SWS_Os_00711, SWS_Os_00712,
SWS_Os_00792, SWS_Os_00801
SRS_Os_80023 The OS shall execute an SWS_Os_00770, SWS_Os_00771,
operation which can be SWS_Os_00802
selected at runtime, in case no
task is going to be scheduled
on a specific core
SRS_Os_80026 It shall be possible to start any SWS_Os_00574, SWS_Os_00575,
of the cores in a multi core SWS_Os_00576, SWS_Os_00577,
system SWS_Os_00584, SWS_Os_00585,
SWS_Os_00676, SWS_Os_00677,
SWS_Os_00678, SWS_Os_00679,
SWS_Os_00680, SWS_Os_00681,
SWS_Os_00682, SWS_Os_00683,
SWS_Os_00684, SWS_Os_00685
SRS_Os_80027 It shall be possible to initialize SWS_Os_00574, SWS_Os_00575,
any of the cores in a multi core SWS_Os_00576, SWS_Os_00577,
system SWS_Os_00584, SWS_Os_00585,
SWS_Os_00676, SWS_Os_00677,
SWS_Os_00678, SWS_Os_00679,
SWS_Os_00680, SWS_Os_00681,
SWS_Os_00682, SWS_Os_00683,
SWS_Os_00684, SWS_Os_00685
7 Functional specification
7.1 Core OS
7.1.1 Background & Rationale
The OSEK/VDX Operating System [15] is widely used in the automotive industry and
has been proven in use in all classes of ECUs found in modern vehicles. The
concepts that OSEK OS has introduced are widely understood and the automotive
industry has many years of collective experience in engineering OSEK OS based
systems.
For these reasons the core functionality of the AUTOSAR OS shall be based upon
the OSEK OS. In particular OSEK OS provides the following features to support
concepts in AUTOSAR:
OSEK OS provides many features in addition to these. Readers should consult the
specification [15] for details.
7.1.2 Requirements
It is too inefficient to achieve timing and memory protection for alarm callbacks. They
are therefore not allowed in specific scalability classes (SWS_Os_00242)
[SWS_Os_00242] ⌈The Operating System module shall only allow Alarm Callbacks
in Scalability Class 1. ⌋ ( )
AUTOSAR OS, when used in an AUTOSAR system, therefore does not need to
support internal communication.
OSEK OS has one special resource called RES_SCHEDULER. This resource has 2
specific aspects:
1. It is always present in the system, even if it is not configured. This means that
the RES_SCHEDULER is always known by the OS.
2. It has always the highest Task priority. This means a Task which allocates this
resource can not be preempted by other Tasks.
Since special cases are always hard to handle (e.g. in this case with respect to timing
protection) AUTOSAR OS handles RES_SCHEDULER as any other resource. This
means that the RES_SCHEDULER is not automatically created. However, a
configuration attribute allows that a resource in AUTOSAR OS can optionally be
assigned the priority of the highest priority task in the system.
For backwards compatibility with OSEK OS systems, see Chapter 12.7 on how to
configure a standard resource called RES_SCHEDULER in a way that make it
compatible with the resource of the same name which is declared automatically in
OSEK OS.
In OSEK OS users must declare Operating System objects with specific macros (e.g.
DeclareTask(), …) An AUTOSAR OS implementation shall not depend on such
declarations and shall (for backwards compatibility) supply macros without
functionality.
There are a number of cases where the behaviour of OSEK OS is undefined. These
cases represent a barrier to portability. AUTOSAR OS tightens the OSEK OS
specification by defining the required behaviour.
[SWS_Os_00424] ⌈The first call to StartOS() (for starting the Operating System)
shall not return. ⌋ ( )
[SWS_Os_00566] ⌈The Operating System API shall check in extended mode all
pointer arguments for a NULL pointer and return E_OS_PARAM_POINTER in extended
status if such an argument is NULL. ⌋ ( )
[SWS_Os_00374] ⌈The Operating System module shall handle all the initialization
and configuration of timers used directly by the Operating System module and not
handled by the GPT driver. ⌋ (SRS_Frt_00020)
[SWS_Os_00384] ⌈The Operating System module shall adjust the read out values of
hardware timers (which drive counters) in such that the lowest value is zero and
consecutive reads return an increasing count value until the timer wraps at its
modulus. ⌋ (SRS_Frt_00030, SRS_Frt_00031)
one or more actions that must occur when it is processed where an action is
the activation of a task or the setting of an event.
An offset in ticks from the start of the schedule table
Each schedule table has a duration in ticks. The duration is measured from zero and
defines the modulus of the schedule table.
At runtime, the Operating System module will iterate over the schedule table,
processing each expiry point in turn. The iteration is driven by an OSEK counter. It
therefore follows that the properties of the counter have an impact on what is
possible to configure on the schedule table.
7.3.2 Requirements
Expiry Point 1 Expiry Point 2 Expiry Point 3 Expiry Point 4 Expiry Point 5
Task Activations Task Activations Task Activations Task Activations Task Activations
TaskA <none> TaskA TaskA TaskB
TaskB TaskE TaskE TaskF
Event Settings Event Settings Event Settings Event Settings Event Settings
EventP:TaskC EventP:TaskC <none> EventQ:TaskC EventP:TaskC
EventP:TaskD EventP:TaskD EventQ:TaskE
InitialOffset=4
Delay=InitialOffset+FinalDelay=14
0 4 12 20 32 40 0
[SWS_Os_00402] ⌈An expiry point shall contain a (possibly empty) set of tasks to
activate. ⌋ ( )
[SWS_Os_00403] ⌈An expiry point shall contain a (possibly empty) set of events to
set. ⌋ ( )
[SWS_Os_00404] ⌈An expiry point shall contain an offset in ticks from the start of
the schedule table. ⌋ ( )
There is no use case for an empty expiry point, so each one must define at least one
action.
[SWS_Os_00407] ⌈An expiry point shall activate at least one task OR set at least
one event. ⌋ ( )
The OS needs to know the order in which expiry points are processed. It is therefore
necessary to ensure that the expiry points on a schedule table can be totally ordered.
This is guaranteed by forcing each expiry point on a schedule table to have a unique
offset.
[SWS_Os_00442] : ⌈Each expiry point on a given schedule table shall have a unique
offset. ⌋ ( )
Iteration over expiry points on a schedule table is driven by an OSEK counter. The
characteristics of the counter – OsCounterMinCycle and
OsCounterMaxAllowedValue – place constraints on expiry point offsets.
Simlarly, constraints apply to the delays between of adjacent expiry points and the
delay to the logical end of the schedule table.
[SWS_Os_00408] ⌈The delay between adjacent expiry points shall be in the range
OsCounterMinCycle .. OsCounterMaxAllowedValue of the underlying counter. ⌋
()
[SWS_Os_00002] ⌈The Operating System module shall process each expiry point
on a schedule table from the Initial Expiry Point to the Final Expiry Point in order of
increasing offset. ⌋ (SRS_Os_00098)
[SWS_Os_00411] ⌈The Operating System module shall make use of ticks so that
one tick on the counter corresponds to one tick on the schedule table. ⌋ ( )
It is possible to activate a task and set (one or more unique) events for the same task
at the same expiry point. The ordering of task activations and event settings
performed from the expiry point could lead to different implementations exhibiting
different behaviour (for example, activating a suspended task and then setting and
event on the task would succeed but if the ordering was reversed then the event
setting would fail). To prevent such non-determinism, it is necessary to enforce a
strict ordering of actions on the expiry point.
[SWS_Os_00412] ⌈The Operating System module shall process all task activations
on an expiry point first and then set events. ⌋ ( )
A schedule table always has a defined state and the following figure illustrates the
different states (for a non-synchronized schedule table) and the transitions between
them.
SCHEDULETABLE_STOPPED
StopScheduleTable()
NextScheduleTable()
StartScheduleTableAbs()
StartScheduleTableRel()
StopScheduleTable() SCHEDULETABLE_NEXT
OR schedule table ends
SCHEDULETABLE_RUNNING
If a schedule table is not active – this means that is not processed by the Operating
System – the state is SCHEDULETABLE_STOPPED. After starting a schedule tables
enters the SCHEDULETABLE_RUNNING state where the OS processes the expiry points.
If the service to switch a schedule table is called a schedule table enters the the
SCHEDULETABLE_NEXT state and waits until the “current” schedule table ends.
A schedule table may or may not repeat after the final expiry point is processed. This
allows two types of behaviour:
1. single-shot – the schedule table processes each expiry point in sequence and
then stops at the end. This is useful for triggering a phased sequence of
actions in response to some trigger
2. repeating – the schedule table processes each expiry point in turn, After
processing the final expiry point, it loops back to the initial expirt point. This is
useful for building applications that perform repeated processing or system
which need to synchronise processing to a driver source.
A repeating schedule table means that each expiry point is repeated at a period
equal to the schedule table duration.
[SWS_Os_00444] ⌈For periodic schedule tables the value of Final Delay shall be in
the range OsCounterMinCycle .. OsCounterMaxAllowedValue of the underlying
counter. ⌋ ( )
[SWS_Os_00194] ⌈After processing the Final Expiry Point, and if the schedule table
is repeating, the Operating System shall process the next Initial Expiry Point, after
Final Delay plus Initial Offset ticks have elapsed. ⌋ ( )
The application is responsible for starting and stopping the processing of a schedule
table.
The figure below illustrates the two different methods for a schedule table driven by a
counter with a modulus of 65536 (i.e. an OsCounterMaxAllowedValue = 65535).
STOPPED RUNNING
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
65530 65532 65534
65531 65533 65535 OS Counter
StartScheduleTableAbs(Tbl,2);
Process Initial Expiry Point when the Counter = 2 + Initial Offset = 2
STOPPED RUNNING
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
65530 65532 65534
65531 65533 65535 OS Counter
StartScheduleTableRel(Tbl,2);
Process Initial Expiry Point when the Counter = Now + 2 + Initial Offset = 1
[SWS_Os_00428] ⌈If schedule table processing has been cancelled before reaching
the Final Expiry Point and is subsequently restarted then
SWS_Os_00358/SWS_Os_00347 means that the re-start occurs from the start of the
schedule table. ⌋ ( )
Schedule tables can be configured (see chapter 10) to start automatically during start
of the Operating System module (like Tasks and Alarms in OSEK OS). OSEK OS
defines a specific order: Autostart of Tasks is performed before autostart of alarms.
AUTOSAR OS extends this with schedule tables.
The absolute time at which the Initial Expiry Point on a schedule table is processed is
under user control. However, if the schedule table repeats then it is not guaranteed
that the absolute count value at which the initial expiry point was first processed is
the same count value at which it is subsequently processed. This is because the
duration of the schedule table need not be equal to the counter modulus.
In many cases it may be important that schedule table expiry points are processed at
specific absolute values of the underlying counter. This is called synchronization.
Typical use-cases include:
1. implicit synchronization – the counter driving the schedule table is the counter
with which synchronization is required. This is typically how synchronization
with time-triggered networking technologies (e.g. FlexRay, TTP) is achieved –
the underlying hardware manages network time synchronization and simply
presents time as an output/compare timer interface to the Operating System.
The following figure shows the possible states for schedule tables with implicit
synchronization.
SCHEDULETABLE_STOPPED
StopScheduleTable()
NextScheduleTable()
StartScheduleTableAbs()
SCHEDULETABLE_NEXT
StopScheduleTable()
SCHEDULETABLE_RUNNING_AND
_SYNCHRONOUS
SCHEDULETABLE_STOPPED StopScheduleTable()
NextScheduleTable()
SCHEDULETABLE_NEXT
StartScheduleTableAbs()
StartScheduleTableRel()
StopScheduleTable()
„previous“ ScheduleTable ends
StopScheduleTable()
StartScheduleTableSync()
SCHEDULETABLE_WAITING SCHEDULETABLE_RUNNING
ABS(CounterValue-GlobalValue)<=PRECISION
StopScheduleTable()
SyncScheduleTable() SetScheduleTableAsync() OR
ABS(CounterValue-GlobalValue)>PRECISION
SCHEDULETABLE_RUNNING_AND
_SYNCHRONOUS
Figure 7.5: States of an explicit synchronized schedule table (not all conditions for transitions
are shown in the picture)
7.4.2 Requirements
The Operating System module does not need to provide any additional support for
implicit synchronization of schedule tables. However, it is necessary to constrain
configuration and runtime control of the schedule table so that ticks on the configured
schedule table can be aligned with ticks on the counter. This requires the range of
the schedule table to be identical to the range of the counter (the equality of tick
resolution of each is guaranteed by the requirements on the schedule table / counter
interaction):
When the schedule table is started at an absolute counter value each expiry point will
be processed when the counter equals the value specified in the service call plus
expiry point’s offset. The common use-case is to ensure that the offsets specified in
the schedule table configuration correspond to absolute values of the underlying
counter. This is achieved trivially using StartScheduleTableAbs(Tbl,0) as shown
below.
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
OS Counter
StartScheduleTableAbs(Tbl,0);
Process Initial Expiry Point when the Counter = 0 + Initial Offset = 2
The following constraints must be enforced between the schedule table, the
Operating System module’s counter and the synchronization counter:
Constraint1:
Constraint2:
50 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Constraint3:
Note that it is in the responsibility of the Operating System module user to verify that
Constraints 2 and 3 are satisfied by their system.
The function of explicit synchronization is for the Operating System module to keep
processing each expiry point at absolute value of the synchronization counter equal
to the expiry point’s offset. This means that explicit synchronization always assumes
that the notional zero of the schedule table has to be synchronized with absolute
value zero on the synchronization counter.
To achieve this, the Operating System module must be told the value of the
synchronization counter by the user. As the modulus of the synchronization counter
and the schedule table are identical, the Operating System module can use this
information to calculate drift. The Operating System module then automatically
adjusts the delay between specially configured expiry points, retarding them or
advancing them as appropriate, to ensure that synchronization is maintained.
7.4.2.2.1 Startup
There are two options for starting an explicitly synchronized schedule table:
Asynchronous start is provided by the existing absolute and relative schedule table
start services. Both of these services set the point at which the initial expiry point is
processed with respect to the driver counter not the synchronization counter. This
allows the schedule table to start running before the value of the synchronization
counter is known.
Synchronous start requires an additional service that starts the schedule table only
after the Operating System module is told the value of the synchronization counter.
The Operating System module must be told the value of the synchronization counter.
Since the schedule table duration is equal to the modulus of the synchronization
counter, the Operating System module can use this to determine the drift between
the current count value on the schedule table time and the synchronization count and
decide whether (or not) any action to achieve synchronization is required.
[SWS_Os_00415] ⌈An
expiry point shall permit the configuration of a
OsScheduleTableMaxShorten that defines the maximum number of ticks that can
be subtracted from expiry point offset. ⌋ ( )
Explicitly synchronized schedule tables allow the tolerance of some drift between the
schedule table value and the synchronization counter value. This tolerance can be
zero, indicating that the schedule table is not considered synchronized unless the
values are indentical..
[SWS_Os_00418] ⌈The Operating System module shall set the state of an explicitly
synchronized schedule table to “running and synchronous” if the deviation is less
than or equal to the configured OsScheduleTblExplicitPrecision threshold. ⌋ ( )
54 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
[SWS_Os_00419] ⌈The Operating System module shall set the state of an explicitly
synchronized schedule table to “running” if the deviation is greater than the
configured OsScheduleTblExplicitPrecision threshold. ⌋ ( )
[SWS_Os_00420] ⌈IF the deviation is non-zero AND the next expiry point is
adjustable AND the table is behind the sync counter
(TableTicksAheadOfSyncCounter <= TableTicksBehindOfSyncCounter) THEN the
OS shall set the next EP to expire delay - min(MaxShorten, Deviation) ticks from the
current expiry. ⌋ ( )
[SWS_Os_00421] ⌈IF the deviation is non-zero AND the next expiry point is
adjustable AND the table is ahead of the sync counter
(TableTicksAheadOfSyncCounter > TableTicksBehindOfSyncCounter) THEN the OS
shall set the next EP to expire delay + min(MaxLengthen, Deviation) ticks from the
current expiry. ⌋ ( )
On processors that do not provide any memory protection hardware it may still be
necessary to provide a “best effort with available resources” scheme for detectable
classes of memory faults. Stack monitoring will identify where a task or ISR has
exceeded a specified stack usage at context switch time. This may mean that there is
considerable time between the system being in error and that fault being detected.
Similarly, the error may have been cleared at the point the fault is notified (the stack
may be less than the specified size when the context switch occurs).
It is not usually sufficient to simply monitor the entire stack space for the system
because it is not necessarily the Task/ISR that was executing that used more than
stack space than required – it could be a lower priority object that was pre-empted.
Significant debugging time can be saved by letting the Operating System correctly
identify the Task/Category 2 ISR in error.
Note that for systems using a MPU and scalability class 3 or 4 a stack overflow may
cause a memory exception before the stack monitoring is able to detect the fault.
7.5.2 Requirements
7.6 OS-Application
7.6.1 Background & Rationale
The Operating System module is responsible for scheduling the available processing
resource between the OS-Applications that share the processor. If OS-Application(s)
are used, all Tasks, ISRs, Counters, Alarms and Schedule tables must belong to an
OS-Application. All objects which belong to the same OS-Application have access to
each other. The right to access objects from other OS-Applications may be granted
during configuration. An event is accessible if the task for which the event can be set
is accessible. Access means that these Operating System objects are allowed as
parameters to API services.
There are services offered by the AUTOSAR OS which give the caller information
about the access rights and the membership of objects. These services are intended
to be used in case of an inter-OS-Application call for checking access rights and
arguments.
Note that Resource obejcts do not belong to any OS-Application, but access to them
must be explicitely granted. (The same principle applies to spinlocks in Multi-Core
systems)
OS-Application Hook
#itsShutdownHook
Shutdow nHook_<Appl>
#itsSchedule 1 0..1
SCHEDULETABLE
* 1
#itsStartupHook Hook
StartupHook_<Appl>
1 0..1
ALARM
#itsAlarm Hook
#itsErrorHook
* ErrorHook_<Appl>
1
1 0..1
TASK
COUNTER
#itsCounter 1 #itsTask - EVENTs (of the TASK)
- One optional restart TASK
* 1 *
ISR
#itsISR
1 *
{XOR}
«realize» «realize»
An OS-Application may acces OS
+itsProvidedServices objects of other OS-Application (e.g.
trusted non-trusted starting an Alarm or setting an Event
TRUSTED_FUNCTION OS-Application OS-Application to anothers OS-Application Task) if
their configuration allows this.
0..* 1
constraints constraints
{privileged mode} {non-privileged mode}
The following figure shows the states and the possible transitions:
APPLICATION_ACCESSIBLE APPLICATION_TERMINATED
AllowAccess()
ProtectionHook with RESTART
OR
TerminateApplication with
RESTART
APPLICATION_RESTARTING
7.6.2 Requirements
[SWS_Os_00446] ⌈The Operating System module shall support the notion of trusted
and non-trusted OS-Applications. ⌋ ( )
[SWS_Os_00500] ⌈The Operating System module shall set the state of all OS-
Applications after the call of StartOS() and before any StartupHook is called to
APPLICATION_ACCESSIBE. ⌋ ( )
It is not possible to provide protection between functions called from the body
of the same Task/Category 2 ISR.
Memory protection will only be possible on processors that provide hardware support
for memory protection.
The memory protection scheme is based on the (data, code and stack) sections of
the executable program.
Stack: An OS-Application comprises a number of Tasks and ISRs. The stack for
these objects, by definition, belongs only to the owner object and there is therefore
no need to share stack data between objects, even if those objects belong to the
same OS-Application.
Memory protection for the stacks of Tasks and ISRs is useful mainly for two reasons:
(1) Provide a more immediate detection of stack overflow and
underflow for the Task or ISR than can be achieved with stack
monitoring
(2) Provide protection between constituent parts of and OS-Application,
for example to satisfy some safety constraints.
61 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Data: OS-Applications can have private data sections and Tasks/ISRs can have
private data sections. OS-Application’s private data sections are shared by all
Tasks/ISRs belonging to that OS-Application.
7.7.1.2 Requirements
[SWS_Os_00198] ⌈The Operating System module shall prevent write access to its
own data sections and its own stack from non-trusted OS-Applications. ⌋ ( )
[SWS_Os_00207] ⌈The Operating System module shall prevent write access to the
OS-Application’s private data sections from other non-trusted OS-Applications. ⌋
(SRS_Os_11005)
[SWS_Os_00208] ⌈The Operating System module may prevent write access to the
private stack of Tasks/Category 2 ISRs of a non-trusted application from all other
Tasks/ISRs in the same OS-Application. ⌋ (SRS_Os_11005)
[SWS_Os_00355] ⌈The Operating System module shall prevent write access to all
private stacks of Tasks/Category 2 ISRs of an OS-Application from other non-trusted
OS-Applications. ⌋ ( )
[SWS_Os_00195] ⌈The Operating System module may prevent write access to the
private data sections of a Task/Category 2 ISR of a non-trusted application from all
other Tasks/ISRs in the same OS-Application. ⌋ (SRS_Os_11005)
[SWS_Os_00356] ⌈The Operating System module shall prevent write access to all
private data sections of a Task/Category 2 ISR of an OS-Application from other non-
trusted OS-Applications. ⌋ ( )
Code Sections
[SWS_Os_00081] ⌈The Operating System module shall provide the ability to provide
shared library code in sections that are executable by all OS-Applications. ⌋
(SRS_Os_11007)
Peripherals
A timing fault in a real-time system occurs when a task or interrupt misses its
deadline at runtime.
AUTOSAR OS does not offer deadline monitoring for timing protection. Deadline
monitoring is insufficient to correctly identify the Task/ISR causing a timing fault in an
AUTOSAR system. When a deadline is violated this may be due to a timing fault
introduced by an unrelated Task/ISR that interferes/blocks for too long. The fault in
this case lies with the unrelated Task/ISR and this will propagate through the system
until a Task/ISR misses its deadline. The Task/ISR that misses a deadline is
therefore not necessarily the Task/ISR that has failed at runtime, it is simply the
earliest point that a timing fault is detected.
If action is taken based on a missed deadline identified with deadline monitoring this
would potentially use false evidence of error to terminate a correct OS-Application in
favour of allowing an incorrect OS-Application to continue running. The problem is
best illustrated by example. Consider a system with the following configuration:
Assuming that all tasks are ready to run at time zero, the following execution trace
would be expected and all tasks would meet their respective deadlines.
.
64 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Now consider the case when tasks A and B behave incorrectly. The figure below
shows both task A and task B executing for longer than specified and task B arriving
2 ticks earlier than specified. Both tasks A and B meet their deadlines. Task C
however, behaves correctly but it fails to meet its deadline because of the incorrect
execution of Tasks A and B. This is fault propagation – a fault in an unrelated part of
the system is causing a correctly functioning part of the system to fail.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Whether a task or ISR meets its deadline in a fixed priority preemptive operating
system like AUTOSAR OS is determined by the following factors:
For safe and accurate timing protection it is necessary for the operating system to
control these factors at runtime to ensure that Tasks/ISRs can meet their respective
deadlines.
AUTOSAR OS prevents timing errors from (1) by using execution time protection to
guarantee a statically configured upper bound, called the Execution Budget, on the
execution time of:
Tasks
Category 2 ISRs
65 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
AUTOSAR OS prevents timing errors from (2) by using locking time protection to
guarantee a statically configured upper bound, called the Lock Budget, on the time
that:
Resources are held by Tasks/Category 2 ISRs
OS interrupts are suspended by Tasks/Category 2 ISRs
ALL interrupts are suspended/disabled by Tasks/Category 2 ISRs
AUTOSAR OS prevents timing errors from (3) by using inter-arrival time protection to
guarantee a statically configured lower bound, called the Time Frame, on the time
between:
A task being permitted to transition into the READY state due to:
o Activation (the transition from the SUSPENDED to the READY state)
o Release (the transition from the WAITING to the READY state)
A Category 2 ISR arriving
An arrival occurs when the Category 2 ISR is recognized by the OS
Inter-arrival time protection for basic tasks controls the time between successive
activations, irrespective of whether activations are queued or not. In the case of
queued activations, activating a basic task which is in the READY or RUNNING state is
a new activation because it represents the activation of a new instance of the task.
Inter-arrival time protection therefore interacts with queued activation to control the
rate at which the queue is filled.
Inter-arrival time protection for extended tasks controls the time between successive
activations and releases. When a task is in the WAITING state and multiple events are
set with a single call to SetEvent() this represents a single release. When a task
waits for one or more events which are already set this represents a notional
Wait/Release/Start transition and therefore is considered as a new release.
The following figure shows how execution time protection and inter-arrival time
protection interact with the task state transition model for AUTOSAR OS.
Terminate
OsTaskExecutionBudget reset
Successful activation of a task already in the RUNNING A task that waits on an event which is already set
state marks the start of a new OsTaskTimeFrame notionally transitions into the WAITING state
Wait
RUNNING
OsTaskExecutionBudget reset
Release
READY
OsTaskTimeFrame started
OsTaskTimeFrame started
Figure 7.12: Time protection interaction with the task state transition model
Notes:
1. Inter-arrival time enforcement on Category 2 ISRs can be used to protect an
ECU from a “babbling idiot” source of interrupts (e.g. a CAN controller taking
an interrupt each time a frame is received from another ECU on the network).
2. Timing protection only applies to Tasks or Category 2 ISRs. There is no
protection for Category 1 ISRs. If timing protection error occurs during a
category 1 ISR, consistency of the Operating System module can not be
guaranteed. Therefore we discourage timing protection in systems with
category 1 interrupts.
3. Timing protection does not apply before the Operating System module is
started.
4. In the case of trusted OS-Applications it is essential that all timing information
is correct, otherwise the system may fail at run-time. For a non-trusted OS-
Application, timing protection can be used to enforce timing boundaries
between executable objects.
7.7.2.2 Requirements
[SWS_Os_00465] ⌈The Operating System module shall limit the inter-arrival time of
tasks to one per OsTaskTimeFrame. ⌋ (SRS_Os_11008)
[SWS_Os_00470] ⌈The Operating System module shall limit the inter-arrival time of
Category 2 ISRs to one per OsIsrTimeFrame. ⌋ (SRS_Os_11008)
Depending on the real hardware support this could mean that DisableAllInterrupts
and SuspendAllInterrupts disable not all interrupts (e.g. all interrupts except of the
interrupt used for timing protection) or that the usage of Category 1 ISRs – which
bypass the Operating System (and also the timing protection) – is limited somehow.
As OS-Applications can interact with the Operating System module through services,
it is essential that the service calls will not corrupt the Operating System module
itself. Service Protection guards against such corruption at runtime.
The OSEK OS already provides some service protection through the status codes
returned from service calls and this will provide the basis for service protection. This
means that service protection will only apply for the extended status of OSEK OS.
However, OSEK OS does not cover all the cases outlined above. The following
sections describe – besides the mandatory extended status – the additional
protection requirements to be applied in each of these cases.
The current OSEK OS’ service calls already return E_OS_ID on invalid objects (i.e.
objects not defined in the OIL file) and E_OS_VALUE for out of range values (e.g.
setting an alarm cycle time less than OsCounterMinCycle).
7.7.3.1.2 Requirements
The current OSEK OS defines the valid calling context for service calls (see [15]),
however protects against only a small set of these invalid calls, e.g. calling
TerminateTask() from a Category 2 ISR.
Protection Hook
Shutdown Hook
Alarm Callback
PostTask Hook
PreTask Hook
Startup Hook
Error Hook
Cat1 ISR
Cat2 ISR
Task
Service
ActivateTask
TerminateTask C
ChainTask C
Schedule C
GetTaskID
GetTaskState
DisableAllInterrupts
EnableAllInterrupts
SuspendAllInterrupts
ResumeAllInterrupts
SuspendOSInterrupts
ResumeOSInterrupts
GetResource
ReleaseResource
SetEvent
ClearEvent C
GetEvent
WaitEvent C
GetAlarmBase
GetAlarm
SetRelAlarm
SetAbsAlarm
CancelAlarm
GetActiveApplicationMode
StartOS
ShutdownOS
GetApplicationID
GetISRID
CallTrustedFunction
CheckISRMemoryAccess
CheckTaskMemoryAccess
CheckObjectAccess
71 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Protection Hook
Shutdown Hook
Alarm Callback
PostTask Hook
PreTask Hook
Startup Hook
Error Hook
Cat1 ISR
Cat2 ISR
Task
Service
CheckObjectOwnership
StartScheduleTableRel
StartScheduleTableAbs
StopScheduleTable
NextScheduleTable
StartScheduleTableSynchron
SyncScheduleTable
GetScheduleTableStatus
SetScheduleTableAsync
IncrementCounter
GetCounterValue
GetElapsedValue
2
TerminateApplication
AllowAccess
GetApplicationState
ControlIdle
GetCurrentApplicationID
ReadPeripheral8
ReadPeripheral16
ReadPeripheral32
WritePeripheral8
WritePeripheral16
WritePeripheral32
ModifyPeripheral8
ModifyPeripheral16
ModifyPeripheral32
DisableInterruptSource
EnableInterruptSource
ClearPendingInterrupt
In the table above “C” indicates that validity is only “Checked in Extended status by
E_OS_CALLEVEL” .
7.7.3.2.2 Requirements
[SWS_Os_00088] ⌈If an OS-Application makes a service call from the wrong context
AND is currently not inside a Category 1 ISR the Operating System module shall not
2
Only in case of self termination.
72 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
perform the requested action (the service call shall have no effect), and return
E_OS_CALLEVEL or the “invalid value” of the service. ⌋ (SRS_Os_11009, SRS_Os_11013)
7.7.3.3.2 Requirements
[SWS_Os_00052] ⌈If a task returns from its entry function without making a
TerminateTask() or ChainTask() call, the Operating System module shall
terminate the task (and call the PostTaskHook() if configured). ⌋ (SRS_Os_11009)
[SWS_Os_00069] ⌈If a task returns from its entry function without making a
TerminateTask() or ChainTask() call AND the error hook is configured, the
Operating System module shall call the ErrorHook() (this is done regardless of
whether the task causes other errors, e.g. E_OS_RESOURCE) with status
E_OS_MISSINGEND before the task leaves the RUNNING state. ⌋ (SRS_Os_11009)
[SWS_Os_00070] ⌈If a task returns from the entry function without making a
TerminateTask() or ChainTask() call and still holds OSEK Resources, the
Operating System module shall release them. ⌋ (SRS_Os_11009, SRS_Os_11013)
[SWS_Os_00239] ⌈If a task returns from the entry function without making a
TerminateTask() or ChainTask() call and interrupts are still disabled, the
Operating System module shall enable them. ⌋ ( )
The Operating System service calls available are restricted according to the calling
context (see Section 7.7.3.2). In a protected system, additional constraints need to
be placed to prevent non-trusted OS-Applications executing API calls that can have a
global effect on the system. Each level of restriction is a proper subset of the
previous level as shown in the figure below.
1. Trusted
2. Non-Trusted
7.7.3.4.2 Requirements
7.7.3.5.1 Background
Section 7.7.3.1 stated that E_OS_ID is returned by OSEK OS service calls when the
object is invalid. Under the protection scheme a service call can be invalid because
the caller does not have valid permissions for the object (a new meaning for multi-
OS-Application systems).
This is a similar case to an object not being accessible in OSEK OS (for example,
when a task tries to get a resource which exists in the system but has not been
configured as used by the task).
7.7.3.5.2 Requirements
Where a processor supports privileged and non-privileged mode it is usually the case
that certain registers, and the instructions to modify those registers, are inaccessible
outside the privileged mode.
On such hardware, executing the Operating System module in privileged mode and
Tasks/ISRs in non-privileged mode protects the registers fundamental to Operating
System module operation from inadvertent corruption by the objects executing in
non-privileged mode. The Operating System module’s services will need to execute
in privileged mode as they will need to modify the registers that are protected outside
this mode.
The Operating System module can use the control registers of the MPU, timer
unit(s), interrupt controller, etc. and therefore it is necessary to protect those registers
against non-trusted OS-Applications.
7.7.4.2 Requirements
Interrupt handling: Where the MCU supports different modes (as discussed in this
section) ISRs will require the Operating System module to do extra work in the ISR()
wrapper. ISRs will typically be entered in privileged mode. If the handler is part of a
non-trusted OS-Application then the ISR() wrapper must make sure that a switch to
non-privileged mode occurs before the handler executes.
Each trusted OS-Application may export services which are callable from other
OS-Applications.
During configuration these trusted services must be configured to be called
from a non-trusted OS-Application.
The call from the non-trusted OS-Application to the trusted service is using a
mechanism (e.g. trap/software interrupt) provided by the Operating System. The
service is passed as an identifier that is used to determine, in the trusted
environment, if the service can be called.
The Operating System offers services to check if a memory region is
write/read/execute accessible from an OS-Application. It also returns information if
the memory region is part of the stack space.
The Operating System software specification does not provide support for »non-
trusted services«.
7.7.5.2 Requirements
The Operating System can detect protection errors based on statically configured
information on what the constituent parts of an OS-Application can do at runtime.
See Section 7.7.
Unlike monitoring, protection facilities will trap the erroneous state at the point the
error occurs, resulting in the shortest possible time between transition into an
erroneous state and detection of the fault. The different kinds of protection errors are
described in the glossary. If a protection error occurs before the Operating System
module is started the behaviour is not defined. If a protection error happens during
shutdown, e.g. in the application-specific shutdown hook, an endless loop between
the shutdown service and the protection hook may occur.
In the case of a protection error, the Operating System module calls a user provided
Protection Hook for the notification of protection errors at runtime. The Protection
Hook runs in the context of the Operating System module and must therefore be
trusted code.
The Operating System module itself needs only to detect an error and provide the
ability to act. The Protection Hook can select one out of four options the Operating
System module provides, which will be performed after returning from the Protection
Hook, depending on the return value of the Protection Hook. The options are:
1. do nothing
78 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Note that forcibly terminating interrupts is handled differently in “forcibly terminate the
faulty ISR” and “forcibly terminate the OS-Application”. If a faulty ISR is forcibly
terminated, the current invocation of the ISR is terminated. A subsequent invocation
is allowed. If the OS-Application is forcibly terminated, then the interrupt source is
also disabled, preventing subsequent interrupts.
The meaning of "do nothing" (PRO_IGNORE) means that the error reaction is
ignored. The PRO_IGNORE is only allowed in specific situations (currently: arrival rate
errors). After the error is detected (e.g. as specified in SWS_Os_00466 or
SWS_Os_00467) the protection hook is called. If the hook returns with PRO_IGNORE
the OS does continue its normal operation. If a service call was the root cause of the
violation (e.g. an ActivateTask()) and protection hook returns PRO_IGNORE the
service call shall continue its operation (e.g. to activate a Task) and return E_OK (if
successful and possible).
Example 1: A task calls ActivateTask(B) and causes a arrival rate violation. The
activation is not performed (SWS_Os_00466) and protection hook is called. When
returning PRO_IGNORE the OS continues and the ActivateTask() service
activates B and returns E_OK.
Example 2: A task A calls SetEvent() for task B (which currently waits for the
event). The OS detects (SWS_Os_00467) an arrival rate violation and performs a
call of the protection hook. When the call returns with PRO_IGNORE, the SetEvent()
service continues and sets the event. Task B changes to READY state and a
rescheduling might happen. The SetEvent() service call will return E_OK to task A.
7.8.2 Requirements
3
The reason for this case is that the Task which is supervised is not necessary active (and can not be e.g. terminated) and it
can be that the caller of the activation is the real problem.
80 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
[SWS_Os_00110] ⌈If the Operating System module shall forcibly terminates an OS-
Application, it:shall
o forcibly terminate all Tasks/ISRs of the OS-Application AND
o cancel all alarms of the OS-Application AND
o stop schedule tables of the OS-Application AND
o disable interrupt sources of Category 2 ISRs belonging to the OS-Application⌋
(SRS_Os_11014)
7.9.1.1 Requirements
The priority of the TASKs drives the scheduling. Since multiple cores run truly
parallel, several TASKs can execute at the same time.
Figure 2: Priorities are assigned to TASKS. The cores schedule independently from each other.
The TASKS T2, T3 and T5 are executed in true parallelism. TASKs with the same priority on the
same core will be executed in order of activation; TASKs with the same priority on different
cores may not be executed in the order of activation, since the cores schedule independent
from each other.
The OS can be entered on each core in parallel. This optimizes scalability towards
multiple cores. The cores schedule independently. This implies that the schedule on
one core does not consider the scheduling on the other cores4. A low priority TASK
on one core may run in parallel with a high priority TASK on another core.
4
This also applies to TASKs with the same priority, bound to different cores. It also means that non-preemptive tasks cannot be
preempted on the core they are running, but tasks on other cores can run in parallel.
82 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
TASKs and ISRs cannot dynamically change cores by means of the scheduling
algorithm.
7.9.2.1 Requirements
A locatable entity is an entity that has to be located entirely on one core. The
assignment of LEs to cores is defined at configuration time
(OsApplicationCoreRef).
In this release of the AUTOSAR standard OS-Applications shall be the LEs. Because
every TASK has to run on some core, the usage of OS-Applications becomes
obligatory in AUTOSAR R4.0 for Multi-Core systems. BSW modules are not allowed
to ignore OS-Applications, even if they do not use any protection mechanisms. This
is independent from the SC class.
On single-core systems OS-Applications are available only for SC3 and SC4
because the mechanism is used to support memory protection and implies the usage
of extended mode. In Multi-core systems OS-Applications are always available
independend of memory protection and on SC1 standard mode shall be possible.
7.9.3.1 Requirements
[SWS_Os_00570] ⌈All TASKs that are assigned to the same OS-Application shall
execute on the same core. ⌋ (SRS_Os_80003, SRS_Os_80005)
[SWS_Os_00571] ⌈All ISRs that are assigned to the same OS-Application shall
execute on the same core. ⌋ (SRS_Os_80003, SRS_Os_80005)
[SWS_Os_00572] ⌈ISR balancing (if supported by the HW) shall be switched off at
boot time by the OS. ⌋ (SRS_Os_80005, SRS_Os_80006)
The way cores are started depends heavily on the hardware. Typically the hardware
only starts one core, referred as the master core, while the other cores (slaves)
remain in halt state until they are activated by the software.
In contrast to such a master-slave system other boot concepts with cores that start
independently from each other are conceivable. However it is possible to emulate
master-slave behavior on such systems by software.
Example:
void main ()
{
StatusType rv;
[…]
switch (GetCoreID())
{
84 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
case OS_CORE_ID_MASTER:
[…]
StartCore(OS_CORE_ID_0, &rv);
StartOS(OSDEFAULTAPPMODE);
break;
case OS_CORE_ID_0:
[…]
StartCore(OS_CORE_ID_1, &rv);
StartOS(DONOTCARE);
break;
otherwise:
StartOS(DONOTCARE);
}
}
StartOS synchronizes all cores twice. The first synchronization point is located
before the StartupHooks are executed, the second after the OS-Application specific
StartupHooks have finished and before the scheduler is started. The exact point
where the second synchronization occurs depends on the implementation, but it shall
be before the scheduling is started. This release of the AUTOSAR specification does
not support timeouts during the synchronization phase. Cores that are activated with
StartCore but do not call StartOS may cause the system to hang. It is in the
responsibility of the integrator to avoid such behavior.
As shown in Figure 3, the StartUpHook is called on every core right after the first
synchronization. However, there is only one StartUpHook in the system. If, for
example, core-individual functionality must be executed during StartupHook the
GetCoreID function can be used to discriminate the individual cores. After the global
StartUpHook has finished each core performs the StartUpHooks of its OS-
Applications . Since OS-Applications are bound to cores the OS-Application specific
StartUpHooks are executed only on the core to which the corresponding OS-
Application is bound.
7.9.4.1 Requirements
[SWS_Os_00576] ⌈It shall be allowed to use only a subset of the cores available on
a µC for the AUTOSAR system. ⌋ (SRS_Os_80006, SRS_Os_80026, SRS_Os_80027)
The AUTOSAR OS controls several cores as stated above. It need not control all
cores of a µC, however. The maximum number of controlled cores shall be
configured within the “OsOS” section of the configuration.
The AUTOSAR OS API provides a StartCore function to start the cores under its
control. The StartCore function takes a scalar value parameter of type
CoreIdType, specifying the core that shall be started. StartCore can be called
more than once on the master core and also on slave cores. Each core can only be
started once, however. For example:
StartCore(OS_CORE_ID_1, &rv1);
StartCore(OS_CORE_ID_2, &rv2);
StartOS(OSDEFAULTAPPMODE);
The StartOS function shall be called on all cores that have been activated by
StartCore. It is not allowed to call StartCore from a core that has already called
StartOS.
Cores that belong to the AUTOSAR system shall be started by the designated
AUTOSAR OS API service StartCore.
7.9.5.1 Requirements
The function StartNonAutosarCore can be used both before and after StartOS.
It is provided to activate cores that are controlled by another OS or no OS at all,
AUTOSAR functions shall not be called on these cores, otherwise the behavior is
unspecified.
7.9.6.1 Requirements
[SWS_Os_00585] ⌈It shall be possible to activate cores that are not controlled by the
AUTOSAR OS before and after calling StartOS. ⌋ (SRS_Os_80006, SRS_Os_80026,
SRS_Os_80027)
87 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
AUTOSAR supports two shutdown concepts, the synchronized shutdown and the
individual shutdown concept. While the synchronized shutdown is triggered by the
new API function ShutdownAllCores(), the individual shutdown is invoked by the
existing API function ShutdownOS().
If a TASK with the proper rights calls “ShutdownAllCores”, a signal is sent to all
other cores to induce the shutdown procedure. Once the shutdown procedure has
started on a core, interrupts and TASKs are not further processed, and no scheduling
will take place, therefore it makes no sense to activate any TASK, however no error
will be generated. It is in the responsibility of the application developer/system
integrator to make sure that any preparations for shutdown on application and basic
software level are completed before calling “ShutdownAllCores”. (e.g. by means of
the ECU state manager).
During the shutdown procedure every core executes its OS-Application specific
ShutdownHook functions, followed by a synchronization point. After all cores have
reached the synchronization point the global ShutdownHook function is executed by
all cores in parallel.
If a TASK calls ShutdownOS the OS will be shut down on the core on which
ShutdownOS has been called. Every core shall be able to invoke ShutdownOS.
Similar to StartOS this function will shutdown the individual core. To shutdown the
whole ECU ShutdownOS has to be called on every core. The function will not return.
Individual shutdown is not supported in AUTOSAR R4.x (AUTOSAR mode
management will not use it).
[SWS_Os_00762] ⌈In cases where the OS detects a fatal internal error all cores
shall be shut down. ⌋ ( )
Protection Hook
Shutdown Hook
Alarm Callback
PostTask Hook
PreTask Hook
Startup Hook
Error Hook
Cat1 ISR
Cat2 ISR
Task
Service
GetNumberOfActivatedCores
GetCoreID
StartCore
StartNonAutosarCore
GetSpinlock
ReleaseSpinlock
TryToGetSpinlock
ShutdownAllCores
Tab. 3: Allowed Calling Context for OS Service Calls
[SWS_Os_00589] ⌈All functions that are not allowed to operate cross core shall
return E_OS_CORE in extended status if called with parameters that require a cross
core operation. ⌋ (SRS_Os_80013)
7.9.9 GetTaskID
GetTaskID can be called both from TASK and ISR2 level. When called from an
interrupt routine, on Single-Core systems, GetTaskID returns either the interrupted
TASK or indicates that no TASK is running. On Multi-Core systems it
Note: All types of interrupts can only be disabled on the local core. This implies that
the interrupt flags on other cores remain in their current state. Scheduling continues
on the other cores. Running ISRs on other cores continue executing.
7.9.10.1 Requirements
TASK activation shall be extended to work across cores. This document will not
specify any implementation details. This functions timing behavior can be slower
when working across cores. If a TASK has to be activated on another core, a
scheduling decision is necessary on that core. If the core has not been started an
error is generated.
7.9.11.1 Requirements
TASK chaining shall be extended to work across cores. This document will not
specify any implementation details. This function’s timing behavior can be slower
when working across cores. If a TASK has to be activated on another core, a
scheduling decision is necessary on that core. If the core has not been activated, an
error is generated.
92 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
7.9.12.1 Requirements
SetEvent shall be extended to work across cores. This document will not specify
any implementation details. This function’s timing behavior can be slower when
working across cores. If the core has not been activated, an error is generated.
7.9.13.1 Requirements
[SWS_Os_00605] ⌈In case of an error when calling SetEvent across cores, the
error handler shall be called on the core on which SetEvent was originally called. ⌋
(SRS_Os_80016)
On a Multi-Core system all cores shall run in the same application mode. If StartOS
is called with the Appmode DONOTCARE, the AppMode of the other cores is used. At
least one core has to define an AppMode other than DONOTCARE.
5
This is the application mode of the Operating System and shall not be confused by other application modes defined in the
AUTOSAR mode management.
93 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
If the application mode is the same on all cores, StartOS will proceed its
task. More details can be found in chapter 7.9.4.
7.9.15.1 Requirements
[SWS_Os_00608] ⌈If more than one core calls StartOS with an AppMode other
than “DONOTCARE”, the AppModes shall be the same. StartOS shall check this at
the first synchronisation point. In case of violation, StartOS shall not start the
scheduling, shall not call any StartupHooks, and shall enter an endless loop on
every core. ⌋ (SRS_Os_80006)
[SWS_Os_00610] ⌈At least one core shall define an AppMode other than
“DONOTCARE”. ⌋ (SRS_Os_80006)
[SWS_Os_00611] ⌈If the IOC is configured, StartOS shall initialize the data
structures of the IOC. ⌋ (SRS_Os_80020)
7.9.16 TASK termination
7.9.16.1 Requirements
7.9.17.1 Requirements
Every core shall be able to invoke shutdown by using the ShutdownOS function. By
calling ShutdownOS only the calling core will enter the shutdown procedure.
If the user wants to shutdown all cores (more or less in parallel)
ShutdownAllCores shall be used.
7.9.18.1 Requirements
The EVENT waiting mechanism must be adapted to the new Multi-Core spinlock
functionality:
A TASK might be de-scheduled when calling WaitEvent, in which case it would not
be able to release the spinlock. WaitEvent must therefore check if the calling TASK
holds a spinlock. As with RESOURCES, spinlocks cannot be occupied by TASKs in
wait state.
7.9.19.1 Requirements
7.9.20.1 Requirements
The Schedule API service must be adapted to the new Multi-Core spinlock
functionality in the same manner as WaitEvent.
7.9.21.1 Requirements
The GetResource function allows mutual exclusion between TASKs on the same
core. The OS generator shall check offline that the TASKs are not on different
cores.(see 7.9.30) and the GetResource function will check this requirement online.
The priority ceiling protocol (used by GetResource) temporarily changes the priority
of a TASK. Such an approach fails on Multi-Core systems as the priorities are local to
each core. Therefore the ceiling protocol is not sufficient to protect a critical section
against access from different cores.
Every HW assigns a unique physical Id to a core. The physical core Id is the only
way to distinguish between cores. The physical core Ids of a µC are not necessarily
consecutive and do not necessarily start with zero.
The SW requires a mechanism to identify a core, e.g. to use core specific variables.
Because the physical core Id usually can not be used as a direct array index for core
specific variables, a logical CoreID is necessary to map physical core Ids to array
indexes. In the SW it is not necessary to know the physical core Id, the logical
CoreID is sufficient.
The function GetCoreID internally maps the physical core Id to the logical CoreID.
The mapping is implementation specific. GetCoreID can be either a C function or a
macro.
7.9.23.1 Requirements
Similarly to Single-Core situation, each operating system (on each core) offers at
least one COUNTER that is derived from a timer. Therefore, it is possible to define
several COUNTERs which belong to different OS-Applications and either resides on
the same or different cores.
The AUTOSAR OS can only increment COUNTERSs on the core on which it resides.
A COUNTER which is assigned to an OS-Application X cannot be incremented by an
OS-Application Y if X and Y are assigned to different cores.
7.9.25.1 Requirements
The quality of the synchronicity depends on the hardware architecture and on the
system configuration. .
7.9.27 ALARMs
As stated above, ALARMS can only be bound to a COUNTER which resides on the
same core. TASKs can be activated and EVENTs can be set with an ALARM action
regardless of the core to which the TASK is bound. The access rights defined by OS-
Applications have to be respected, however. Additionaly it shall be allowed to
manipulate ALARMS when they are bound to other cores. The API-services
SetRelAlarm, SetAbsAlarm, and CancelAlarm can be used to manipulate
parameters of ALARMs on other cores.
7.9.27.1 Requirements
Similarly to ALARMs, schedule tables can be used to activate TASKs and set
EVENTs. As with ALARMs, a schedule table can only be bound to a COUNTER
which resides on the same core.
7.9.28.1 Requirements
A spinlock is a busy waiting mechanism that polls a (lock) variable until it becomes
available. Typically, this requires an atomic “test and set” functionality, the details of
which are implementation specific.
Figure 7: A deadlock situation caused by interference, the high priority TASK spins indefinitely
because the low priority TASK has occupied the spinlock. In such cases the second
GetSpinlock call will return with an error
A user can protect a TASK against such a situation by, for example, rapping
the spinlock with SuspendAllInterrupts, so that it cannot be interfered by
other TASKS. The OS can do this automatically for the caller see configuration
parameter OsSpinlockLockMethod (on page 102).
A second deadlock situation can be created by nested spinlocks calls, as illustrated
in Figure 8.
Figure 8: This figure shows a typical deadlock caused by two spinlocks taken in different order
by TASKS on two different cores.
Figure 9: This figure shows an example in which two TASKS have access to a set of spinlocks
S1 -- S6. It is allowed to occupy the spinlocks in the predefined order and it is allowed to skip
spinlocks. If multiple spinlocks are occupied at the same time, locking and unlocking has to
occur in strict LIFO order.
The spinlock mechanism is not deadlock free by itself. The order in which spinlocks
from Tasks/ISRs are requested has to be mentioned in the configuration description.
If a task occupies a spinlock, scheduling shall be restricted.
7.9.29.1 Requirements
The linked list of spinlocks must be free of cycles to allow correct nesting of spinlocks
in order to prevent deadlocks.
The OS generator tool must check that an OSApplication does not get assigned to a
non existing core. Additional checks at configuration time, e.g. by an AUTOSAR
description editor are recommended.
7.9.30.1 Requirements
[SWS_Os_00666] ⌈The OS generator tool shall return with an error if the linked list
of spinlocks is not free of cycles. ⌋ (SRS_Os_80021)
Before scheduling starts the AUTOSAR Operating System6 activates all auto-start
objects that are configured. This mechanism shall work similar on a Multi-Core
system. Before scheduling starts, the Multi-Core OS shall activate all configured
auto-start objects on the respective core. Due to the fact that OS-Applications are
defined as the locatable entity no further configuration container is required. Auto-
start objects are already configured as part of an OS-Application.
7.9.31.1 Requirements
6
StartOS
106 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
All AUTOSAR software, both BSW and software components, must belong to an OS-
Application (s. 7.9.3), but not necessarily to the same one. It is expected that the
BSW will be trusted code, but it shall be defined as one or more OS-Applications.
In systems with only one core, the IOC can be omitted completely, if just one OS-
Application is available, or if no OS-Application uses memory protection
mechanisms.
7.10.2 IOC - General purpose
The IOC provides communication services which can be accessed by clients which
need to communicate across OS-Application boundaries on the same ECU.
The RTE uses IOC services to communicate across such boundaries. All
communication must be routed through the RTE on sender (or client) and on receiver
(or server) side.
Direct access to IOC services by clients other than the RTE is currently not
supported, but possible, if the client (e.g. a CDD) provides a hand written or
generated IOC Configuration Description as specified and specific callback functions
if necessary. Only sender/receiver communication is supported however by the IOC.
To keep the RTE as hardware independent as possible, all inter OS-Application and
inter core communication mechanisms and implementation variants are
encapsulated in the IOC. The IOC internal functionality is dependent on hardware
architecture properties, in particular on the memory architecture.
The IOC has to guarantee data consistency in inter OS-Application and inter core
(Multi-Core systems) communication, this means in particular:
- In queued communication the sequential order of communication
operations shall remain unchanged. In the N:1 communication case, the
order of the messages from the different sources is a property of the
implementation.
- The content of all data sent in one communication operation shall remain
unchanged, i.e. each communication operation shall be treated as atomic
operation.
7.10.3 IOC functionality
7.10.3.1 Communication
The IOC provides sender-receiver (signal passing) communication only. The RTE (or
adapted BSW modules in a future release of this specification) translates Client-
Server invocations and response transmissions into Sender-Receiver
communication.
1:1, N:1 and N:M (unqueued only) communication are supported by the IOC.
The IOC allows the transfer of one data item per atomic communication operation. A
data item can either be a value for atomic basic data types or a reference for
complex data structures. The data structure must be implemented as a single
memory block, however. This way the data item can be transmitted in one piece. The
IOC does not need to know the internal data structure. The basic memory address
and length (which can be calculated from the type of the data item) is sufficient. The
IOC does, e.g., not support a conversion of endianness between cores.
Transferring more than one data item in one operation is also supported for 1:1
communication only. In this case several types and memory addresses have to be
used by the IOC function. The advantage compared to sequential IOC calls is that
mechanisms to open memory protection boundaries and to notify the receiver have
to be executed just once. Additionally, all data items are guaranteed to be consistent,
because they are transferred in one atomic operation.
The IOC provides both, unqueued (Last-is-Best, data semantics) or queued (First-In-
First-Out, event semantics) communication operations. If present, the IOC internal
queue has a configurable length.
7.10.3.2 Notification
The IOC optionally notifies the receiver as soon as the transferred data is available
for access on the receiver side, by calling a configured callback function which gets
provided by the user of the communication.
In certain cases, it might not be necessary to trigger an ISR to notify the receiver.
The IOC generator can then select the appropriate IOC internal notification method
based on the hardware architecture and other constraints. This might be more
efficient than an ISR for communication between OsApplications on the same core.
The notification might be handled completely by the client of the IOC, e.g. when the
RTE calls the IOC send function, and then notifies the receiver side RTE that new
data are available from the IOC. In this case, the IOC is not affected at all by the
details of the notification mechanism.
In case such alternative solutions prove to be more efficient, the IOC internal
notification might get removed in future AUTOSAR releases.
7.10.4 IOC interface
The interface between RTE and IOC shall be similar to the interface between
Software Components and the RTE, i.e. by generating specific interfaces for each
communication operation instead of providing a generic API.
This supports optimization methods (like function inlining or replacing function calls
by macros) much better than standardized interfaces. Most of the optimization can be
performed offline at code generation time instead of consuming valuable real-time
resources.
There is a unique set of IOC service APIs (at least to send and receive data) for each
data communication specified in the IOC Configuration Description. Each service API
gets generated and can be identified by a unique Id for each data communication. In
case of N:1 communication, each sender must use its own API.
The same IOC service API and hence the same 1:1 communication can get used by
more than one runnable inside the same SWC both on sender and on receiver side.
However, the IOC functions are not reentrant, because otherwise e.g. spinlock errors
could occur in case the IOC uses spinlocks in Multi-Core systems. The same IOC
API must therefore only be called sequentially. This is no problem, if all runnable
entities are scheduled within the same TASK, otherwise the caller is responsible to
guarantee that the same IOC API is not called again before it returns from a different
invocation.
Software Components may access the IOC only via RTE. Only the RTE decides
which communication services to use to support the communication needs of
Software Components.
Direct access to IOC services by BSW modules is not supported, but allowed for
CDDs and other modules, if unavoidable. The clients have to provides a hand written
or generated IOC Configuration Description as specified. In case of notification of the
receiver, a specific callback function has to be specified and provided by the client.
Only sender/receiver communication is supported however by the IOC.
7.10.5 IOC internal structure
The IOC may enter the privileged mode to cross the protection boundaries between
OS-Applications. The IOC therefore has to be part of the OS. Note that functionality
that is placed in the kernel context might be non-interruptible by TASKs or ISR2. The
functionality can be interrupted by Cat1 ISRs, however.
The IOC send service writes data into a buffer located in a memory area which is
shared with the receiving communication partners (This is one possible
implementation example using shared memory). Depending on the hardware
architecture and other constraints, different implementation options might be
available within the IOC. These options shall be transparent to the client (RTE),
however.
The IOC ensures data consistency, i.e. there is a protection against concurrent
access to the same data from all senders and the receiver for protection against
inconsistent behavior and data corruption. The implementation can be hardware
dependent.
In systems with shared memory, there can be a specific communication buffer for
each data item in a memory section which is shared between the sending and
receiving OS-Applications.
Data element specific interfaces between RTE and IOC require extensive code
generation. Instead of generating the IOC together with the RTE, a sequential code
generation process is used, to separate generic RTE code generation and hardware
dependent IOC code generation as much as possible. The following steps shall be
performed:
There are possibly multiple sources which contribute to the IOC configuration (e.g.,
RTE, CDD). The main input will come from the RTE generator. Other sources for the
IOC Configuration Description (not supported in this specification revision) might be
BSW module configuration tools or non-AUTOSAR components, which are allowed
to use BSW services.
In ECUs with only one OS-Application, the IOC Configuration Description can be
omitted.
7.10.7 IOC integration examples
This section describes two typical use cases that show how the IOC can support
communication between OS-Applications. In both examples the OS-Applications are
located on different cores of a Multi-Core system.
Because the communication crosses core boundaries, the RTE invokes the IOC to
transfer the data from core 0 to core 1.
call is mapped to an
IocSend_<Id> (<data>)
call.
Core 0 Core 1
1 2
RTE RTE
D>
<I
Io
IocReceive_<ID>
e_
cS
IocSend_<ID>
v
en
ei
Part of
d_
ec 2 SW-C
Task 2
<
cR
ID
Io
>
OS Function or
macro
IOC
Function call
1 2
Buffer Data flow
Buffering
mechanism
In this example, the IocSend service writes the data into a buffer, located in a shared
memory area which can get read by the receiver via the IOC.
On the receiving side, the receiving runnable gets invoked periodically. The
Rte_Receive_<port>_<item> (..., <data>)
call is mapped to an
IocReceive_<Id> (<data>)
call to read data from the IOC internal queue. An additional queue within the RTE is
not necessary for 1:1 communication.
The IOC generator generates all the send and receive functions. The functions might
be defined as macros for optimization purposes.
- 1:1 communication.
The RTE realizes the service on client side by mapping the client/server call to a
sender/receiver communication. Because the communication crosses core
boundaries, the RTE uses the IOC to transfer the data from Core 0 to Core 1.
call is mapped to a
IocSend_<Id> (<data>)
call to transmit the parameters over the IOC to the core hosting the server runnable.
Core 0 Core 1
IocReceive_<ID>
IocSend_<ID>
Se
ceive
nd
Part of
_
2 SW-C
<ID
Task 2
IocRe
>
Function or
OS macro
Function call
IOC
Data flow
1 2
Notification
Buffer
Buffering
mechanism
After writing the data into the IOC internal queue buffer, the Rte_Call function uses
an OS call to notify the receiver by activating the server TASK on the receiving core.
This TASK is provided by the RTE. This TASK body is responsible for reading the
data from the IOC buffer by calling IocReceive function and for forwarding the data to
the server runnable. Depending on the return value of the IOC function, the
113 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
IocReceive and server runnable calls might be repeated several times to empty the
IOC internal queued buffer (if specified).
The result of the service on Core 1 is transferred back to the client on Core 0 in a
similar way. The communication path of the result is not displayed in Figure 11.
This kind of port to port communication with notification by the RTE is suitable for:
- Sender/receiver communication with notification
- Client/server communication. In this case the RTE has to provide services
to map the server call into 1:1 sender/receiver communication for the
server call and another sender/receiver communication to return the result
to the client
- Queued or unqueued communication
- 1:1 communication, if the receiver does not poll for data periodically (In this
case, the solution in example 1 might have been more suitable)
- N:1 communication.
7.10.8 Future extensions
Some features are not supported by the first release of this specification, but might
get added in a later release:
In the future, the IOC will handle direct and efficient communication among
BSW modules or between BSW modules and Software Components (via the
RTE) located in different OS applications. Additional support of direct access
from BSW modules to IOC services will be added.
Other notification options (like activation of a specified TASK on receiver side)
might be added later to the IOC.
In order to customize the operating system to the needs of the user and to take full
advantage of the processor features the operating system can be scaled according to
the following scalability classes
Described in Section
Scalability Class 1
Scalability Class 2
Scalability Class 3
Scalability Class 4
Feature Hardware requirements
OSEK OS (all 7.1
conformance classes)
Counter Interface 8.4.17
SWFRT Interface 8.4.18,
8.4.19
Schedule Tables 7.3
Stack Monitoring 7.5
ProtectionHook 7.8
Timing Protection 7.7.2 Timer(s) with high priority
interrupt
Global Time 7.4 Global time source
/Synchronization Support
Memory Protection 7.7.1, MPU
7.7.4
OS-Applications 7.6, 7.12
Service Protection 7.7.3
CallTrustedFunction 7.7.5 (Non-)privileged Modes
Scalability Class 2
Scalability Class 3
Scalability Class 4
Feature
Minimum number of Schedule 2 8 2 8
Tables supported
Minimum number of OS- 0 0 2 2
Applications supported
Minimum number of software 8 8 8 8
Counters supported
7.11.2 Requirements
[SWS_Os_00327] ⌈The Operating System module shall always use extended status
in Scalability Class 3 and 4. ⌋ ( )
Hook routines as defined in OSEK OS run at the level of the Operating System
module and therefore can only belong to the trusted environment. Furthermore, these
hook routines are global to the system (system-specific) and will probably be
supplied by the ECU integrator.
7.12.2 Requirements
[SWS_Os_00439] ⌈The Operating System module shall provide the OSEK error
macros (OSError…()) to all configured error hooks AND there shall be two (like in
OIL) global configuration parameters to switch these macros on or off. ⌋ ( )
StartupHook
[SWS_Os_00236] ⌈If both a system-specific and one (or more) application specific
startup hook(s) are configured, the Operating System module shall call the system-
specific startup hook before the application-specific startup hook(s). ⌋ ( )
ShutdownHook
[SWS_Os_00237] ⌈If both a system-specific and one (or more) application specific
shutdown hook(s) are configured, the Operating System module shall call the
system-specific shutdown hook after the application-specific shutdown hook(s). ⌋ ( )
Error Hook
To allow access to such registers even from non-trusted applications the Operating
Systems offers the following APIs to read, write and modify registers:
In order to control the access to the registers the access has to be configured for
each OsApplication. By this the Os can check during run-time if a caller has sufficient
rights.
7.13.2 Requirements
7.14.2 Requirements
Note: This does not necessarily guarantee that the interrupt request is cleared
successfully, i.e. the ISR may still be serviced afterwards. (This may happen due to
racing conditions or as the request needs to be cleared in the requesting hardware
unit also.)
The following table contains all error codes which might be reported from the OS
(besides those already defined in [15])
8 API specification
This chapter contains the APIs offered by the operating system. Note that not all
services are available in all scalability classes, and that the behavior of some
services is extended for specific scalability classes. For example, API to relatively
start a schedule table has an additional check if the schedule table allows implicit
synchronization. This check is only performed in SC2 and SC4 where
synchronization of schedule tables is supported.
8.1 Constants
8.1.1 Error codes of type StatusType
[SWS_Os_91007] ⌈
Name: AppModeType
Type: Enumeration
Range: DONOTCARE -- --
Description: AppMode of the core shall be inherited from another core.
⌋ ()
[SWS_Os_91002] ⌈
Name: TotalNumberOfCores
Type: scalar
Range: 1..65535 -- --
Description: The total number of cores
⌋ ()
8.2 Macros
OSMEMORY_IS_READABLE(<AccessType>)
OSMEMORY_IS_WRITEABLE(<AccessType>)
OSMEMORY_IS_EXECUTABLE(<AccessType>)
OSMEMORY_IS_STACKSPACE(<AccessType>)
These macros return a value not equal to zero if the memory is readable / writable /
executable or stack space. The argument of the macros must be of type
AccessType. Typically the return value of the service
Check[Task|ISR]MemoryAccess() is used as argument for these macros.
[SWS_Os_00772] ⌈
Name: ApplicationType
Type: uint32
Range: INVALID_OSAPPLICATION -- --
Description: This data type identifies the OS-Application.
⌋ ()
8.3.2 ApplicationStateType
[SWS_Os_00773] ⌈
Name: ApplicationStateType
Type: scalar
Range: APPLICATION_ACCESSIBLE -- --
APPLICATION_RESTARTING -- --
APPLICATION_TERMINATED -- --
Description: This data type identifies the state of an OS-Application.
⌋ ()
8.3.3 ApplicationStateRefType
[SWS_Os_00774] ⌈
Name: ApplicationStateRefType
Type: pointer
Description: This data type points to location where a ApplicationStateType can be stored.
⌋ ()
8.3.4 TrustedFunctionIndexType
[SWS_Os_00775] ⌈
Name: TrustedFunctionIndexType
Type: scalar
Description: This data type identifies a trusted function.
⌋ ()
8.3.5 TrustedFunctionParameterRefType
[SWS_Os_00776] ⌈
Name: TrustedFunctionParameterRefType
Type: pointer
Description: This data type points to a structure which holds the arguments for a call to a
trusted function.
⌋ ()
8.3.6 AccessType
[SWS_Os_00777] ⌈
Name: AccessType
Type: integral
Description: This type holds information how a specific memory region can be accessed.
⌋ ()
8.3.7 ObjectAccessType
[SWS_Os_00778] ⌈
Name: ObjectAccessType
Type: --
Range: ACCESS -- --
NO_ACCESS -- --
Description: This data type identifies if an OS-Application has access to an object.
⌋ ()
8.3.8 ObjectTypeType
[SWS_Os_00779] ⌈
Name: ObjectTypeType
Type: --
Range: OBJECT_TASK -- --
OBJECT_ISR -- --
OBJECT_ALARM -- --
OBJECT_RESOURCE -- --
OBJECT_COUNTER -- --
OBJECT_SCHEDULETABLE -- --
Description: This data type identifies an object.
⌋ ()
8.3.9 MemoryStartAddressType
[SWS_Os_00780] ⌈
Name: MemoryStartAddressType
Type: --
Description: This data type is a pointer which is able to point to any location in the MCU
address space.
⌋ ()
8.3.10 MemorySizeType
[SWS_Os_00781] ⌈
Name: MemorySizeType
Type: --
Description: This data type holds the size (in bytes) of a memory region.
⌋ ()
8.3.11 ISRType
[SWS_Os_00782] ⌈
Name: ISRType
Type: --
Range: INVALID_ISR -- --
Description: This data type identifies an interrupt service routine (ISR).
⌋ ()
8.3.12 ScheduleTableType
[SWS_Os_00783] ⌈
Name: ScheduleTableType
Type: --
Description: This data type identifies a schedule table.
⌋ ()
8.3.13 ScheduleTableStatusType
[SWS_Os_00784] ⌈
Name: ScheduleTableStatusType
Type: --
Range: SCHEDULETABLE_STOPPED -- --
SCHEDULETABLE_NEXT -- --
SCHEDULETABLE_WAITING -- --
SCHEDULETABLE_RUNNING -- --
SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS -- --
Description: This type describes the status of a schedule. The status can be one of the following:
o The schedule table is not started (SCHEDULETABLE_STOPPED)
o The schedule table will be started after the end of currently running schedule table (schedule
table was used in NextScheduleTable() service) (SCHEDULETABLE_NEXT)
o The schedule table uses explicit synchronization, has been started and is waiting for the global
time. (SCHEDULETABLE_WAITING)
125 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
o The schedule table is running, but is currently not synchronous to a global time source
(SCHEDULETABLE_RUNNING)
o The schedule table is running and is synchronous to a global time source
(SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS)
⌋ ()
8.3.14 ScheduleTableStatusRefType
[SWS_Os_00785] ⌈
Name: ScheduleTableStatusRefType
Type: --
Description: This data type points to a variable of the data type ScheduleTableStatusType.
⌋ ()
8.3.15 ProtectionReturnType
[SWS_Os_00787] ⌈
Name: ProtectionReturnType
Type: --
Range: PRO_IGNORE -- --
PRO_TERMINATETASKISR -- --
PRO_TERMINATEAPPL -- --
PRO_TERMINATEAPPL_RESTART -- --
PRO_SHUTDOWN -- --
Description: This data type identifies a value which controls further actions of the OS on return
from the protection hook.
⌋ ()
8.3.16 RestartType
[SWS_Os_00788] ⌈
Name: RestartType
Type: --
Range: RESTART -- --
NO_RESTART -- --
Description: This data type defines the use of a Restart Task after terminating an OS-
Application.
⌋ ()
8.3.17 PhysicalTimeType
[SWS_Os_00789] ⌈
Name: PhysicalTimeType
Type: --
Description: This data type is used for values returned by the conversion macro (see OS393())
126 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
OS_TICKS2<Unit>_<Counter>().
⌋ ()
8.3.18 CoreIdType
[SWS_Os_00790] ⌈
Name: CoreIdType
Type: scalar
Range: OS_CORE_ID_MASTER -- refers to the master core, may be an
alias for OS_CORE_ID_<x>
OS_CORE_ID_0..OS_CORE_ID_65533 -- refers to logical core 0, core 1 etc.
Description: CoreIdType is a scalar that allows identifying a single core. The CoreIdType
shall represent the logical CoreID
⌋ ()
8.3.19 SpinlockIdType
[SWS_Os_00791] ⌈
Name: SpinlockIdType
Type: scalar
Range: 1..65535 -- 0x01, 0x02, ...: identifies a spinlock instance
INVALID_SPINLOCK -- represents an invalid spinlock instance
Description: SpinlockIdType identifies a spinlock instance and is used by the API functions:
GetSpinlock, ReleaseSpinlock and TryToGetSpinlock.
⌋ ()
8.3.20 TryToGetSpinlockType
[SWS_Os_00792] ⌈
Name: TryToGetSpinlockType
Type: Enumeration
Range: TRYTOGETSPINLOCK_SUCCESS -- Spinlock successfully occupied
TRYTOGETSPINLOCK_NOSUCCESS -- Unable to occupy the spinlock
Description: The TryToGetSpinlockType indicates if the spinlock has been occupied or not.
⌋ (SRS_Os_80021)
8.3.21 IdleModeType
[SWS_Os_00793] ⌈
Name: IdleModeType
Type: scalar
Range: IDLE_NO_HALT -- the core does not perform any specific actions during idle
time
Description: This data type identifies the idle mode behavior.
⌋ ()
8.3.22 AreaIdType
[SWS_Os_91000] ⌈
Name: AreaIdType
127 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Type: scalar
Range: 0..65534 -- identifies a peripheral area
Description: AreaIdType identifies a peripheral area and is used by the API functions:
ReadPeripheralX, WritePeripheralX and ModifyPeripheralX
⌋ ()
8.4.1 GetApplicationID
[SWS_Os_00016] ⌈
Service name: GetApplicationID
Syntax: ApplicationType GetApplicationID(
void
)
Service ID[hex]: 0x00
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
ApplicationType <identifier of running OS-Application> or
Return value:
INVALID_OSAPPLICATION
Description: This service determines the OS-Application (a unique identifier has to be allocated
to each application) where the caller originally belongs to (was configured to).
⌋ ()
8.4.2 GetCurrentApplicationID
[SWS_Os_00797] ⌈
Service name: GetCurrentApplicationID
128 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
8.4.3 GetISRID
[SWS_Os_00511] ⌈
Service name: GetISRID
Syntax: ISRType GetISRID(
void
)
Service ID[hex]: 0x01
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
ISRType <Identifier of running ISR> or
Return value:
INVALID_ISR
Description: This service returns the identifier of the currently executing ISR.
⌋ ()
[SWS_Os_00263] ⌈If called from category 2 ISR (or Hook routines called inside a
category 2 ISR), GetISRID() shall return the identifier of the currently executing ISR.
⌋ ( )
[SWS_Os_00264] ⌈If its caller is not a category 2 ISR (or Hook routines called inside
a category 2 ISR), GetISRID() shall return INVALID_ISR. ⌋ ( )
8.4.4 CallTrustedFunction
[SWS_Os_00097] ⌈
Service name: CallTrustedFunction
Syntax: StatusType CallTrustedFunction(
TrustedFunctionIndexType FunctionIndex,
TrustedFunctionParameterRefType FunctionParams
)
Service ID[hex]: 0x02
Sync/Async: Depends on called function. If called function is synchronous then service is
synchronous. May cause rescheduling.
Reentrancy: Reentrant
FunctionIndex Index of the function to be called.
FunctionParams Pointer to the parameters for the function - specified by the
Parameters (in):
FunctionIndex - to be called. If no parameters are provided, a
NULL pointer has to be passed.
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No Error
Return value:
E_OS_SERVICEID: No function defined for this index
Description: A (trusted or non-trusted) OS-Application uses this service to call a trusted
function
⌋ ()
[SWS_Os_00563] ⌈The OperatingSystem shall not schedule any other Tasks which
belong to the same OS-Application as the non-trusted caller of the service. It shall be
done by priority ceiling. Also interrupts of Category 2 which belong to the same OS-
Application shall be disabled during the execution of the service.⌋ ( )
8.4.5 CheckISRMemoryAccess
[SWS_Os_00512] ⌈
Service name: CheckISRMemoryAccess
Syntax: AccessType CheckISRMemoryAccess(
ISRType ISRID,
MemoryStartAddressType Address,
MemorySizeType Size
)
Service ID[hex]: 0x03
Sync/Async: Synchronous
Reentrancy: Reentrant
ISRID ISR reference
Parameters (in): Address Start of memory area
Size Size of memory area
Parameters None
(inout):
Parameters (out): None
Return value: AccessType Value which contains the access rights to the memory area.
Description: This service checks if a memory region is write/read/execute accessible and also
returns information if the memory region is part of the stack space.
⌋ ()
[SWS_Os_00313] ⌈If an access right (e.g. “read”) is not valid for the whole memory
area specified in a call of CheckISRMemoryAccess(), CheckISRMemoryAccess()
shall yield no access regarding this right. ⌋ ( )
8.4.6 CheckTaskMemoryAccess
[SWS_Os_00513] ⌈
Service name: CheckTaskMemoryAccess
Syntax: AccessType CheckTaskMemoryAccess(
TaskType TaskID,
MemoryStartAddressType Address,
MemorySizeType Size
)
Service ID[hex]: 0x04
Sync/Async: Synchronous
Reentrancy: Reentrant
TaskID Task reference
Parameters (in): Address Start of memory area
Size Size of memory area
Parameters None
(inout):
Parameters (out): None
Return value: AccessType Value which contains the access rights to the memory area.
Description: This service checks if a memory region is write/read/execute accessible and also
returns information if the memory region is part of the stack space.
⌋ ()
[SWS_Os_00314] ⌈If an access right (e.g. “read”) is not valid for the whole memory
area specified in a call of CheckTaskMemoryAccess(),
CheckTaskMemoryAccess() shall yield no access regarding this right. ⌋ ( )
8.4.7 CheckObjectAccess
[SWS_Os_00256] ⌈
Service name: CheckObjectAccess
Syntax: ObjectAccessType CheckObjectAccess(
ApplicationType ApplID,
ObjectTypeType ObjectType,
void ...
)
Service ID[hex]: 0x05
133 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Sync/Async: Synchronous
Reentrancy: Reentrant
ApplID OS-Application identifier
Parameters (in): ObjectType Type of the following parameter
... The object to be examined
Parameters None
(inout):
Parameters (out): None
ObjectAccessType ACCESS if the ApplID has access to the object
Return value:
NO_ACCESS otherwise
Description: This service determines if the OS-Applications, given by ApplID, is allowed to use
the IDs of a Task, Resource, Counter, Alarm or Schedule Table in API calls.
⌋ ()
8.4.8 CheckObjectOwnership
[SWS_Os_00017] ⌈
Service name: CheckObjectOwnership
Syntax: ApplicationType CheckObjectOwnership(
ObjectTypeType ObjectType,
void ...
)
Service ID[hex]: 0x06
Sync/Async: Synchronous
Reentrancy: Reentrant
ObjectType Type of the following parameter
Parameters (in):
... The object to be examined
Parameters None
(inout):
Parameters (out): None
ApplicationType <OS-Application>: the OS-Application to which the object
Return value: ObjectType belongs or
INVALID_OSAPPLICATION if the object does not exists
134 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Description: This service determines to which OS-Application a given Task, ISR, Counter,
Alarm or Schedule Table belongs
⌋ ()
8.4.9 StartScheduleTableRel
[SWS_Os_00347] ⌈
Service name: StartScheduleTableRel
Syntax: StatusType StartScheduleTableRel(
ScheduleTableType ScheduleTableID,
TickType Offset
)
Service ID[hex]: 0x07
Sync/Async: Synchronous
Reentrancy: Reentrant
ScheduleTableID Schedule table to be started
Parameters (in): Offset Number of ticks on the counter before the the schedule table
processing is started
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No Error
E_OS_ID (only in EXTENDED status): ScheduleTableID not
valid.
Return value:
E_OS_VALUE (only in EXTENDED status): Offset is greater
than (OsCounterMaxAllowedValue - InitialOffset) or is equal to 0.
E_OS_STATE: Schedule table was already started.
Description: This service starts the processing of a schedule table at "Offset" relative to the
"Now" value on the underlying counter.
⌋ ()
8.4.10 StartScheduleTableAbs
[SWS_Os_00358] ⌈
Service name: StartScheduleTableAbs
Syntax: StatusType StartScheduleTableAbs(
ScheduleTableType ScheduleTableID,
TickType Start
)
Service ID[hex]: 0x08
Sync/Async: Synchronous
Reentrancy: Reentrant
ScheduleTableID Schedule table to be started
Parameters (in):
Start Absolute counter tick value at which the schedule table is started
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No Error
Return value:
E_OS_ID (only in EXTENDED status): ScheduleTableID not
valid
E_OS_VALUE (only in EXTENDED status): "Start" is greater
than OsCounterMaxAllowedValue
E_OS_STATE: Schedule table was already started
Description: This service starts the processing of a schedule table at an absolute value "Start"
on the underlying counter.
⌋ ()
8.4.11 StopScheduleTable
[SWS_Os_00006] ⌈
Service name: StopScheduleTable
Syntax: StatusType StopScheduleTable(
ScheduleTableType ScheduleTableID
)
Service ID[hex]: 0x09
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ScheduleTableID Schedule table to be stopped
137 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No Error
E_OS_ID (only in EXTENDED status): ScheduleTableID not
Return value:
valid.
E_OS_NOFUNC: Schedule table was already stopped
Description: This service cancels the processing of a schedule table immediately at any point
while the schedule table is running.
⌋ ()
8.4.12 NextScheduleTable
[SWS_Os_00191] ⌈
Service name: NextScheduleTable
Syntax: StatusType NextScheduleTable(
ScheduleTableType ScheduleTableID_From,
ScheduleTableType ScheduleTableID_To
)
Service ID[hex]: 0x0a
Sync/Async: Synchronous
Reentrancy: Reentrant
ScheduleTableID_From Currently processed schedule table
Parameters (in):
ScheduleTableID_To Schedule table that provides its series of expiry points
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No error
E_OS_ID (only in EXTENDED status):
Return value: ScheduleTableID_From or ScheduleTableID_To
not valid
E_OS_NOFUNC: ScheduleTableID_From not started
8.4.13 StartScheduleTableSynchron
[SWS_Os_00201] ⌈
Service name: StartScheduleTableSynchron
Syntax: StatusType StartScheduleTableSynchron(
ScheduleTableType ScheduleTableID
)
Service ID[hex]: 0x0b
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ScheduleTableID Schedule table to be started
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No Error
E_OS_ID (only in EXTENDED status): ScheduleTableID not
Return value:
valid
E_OS_STATE: Schedule table was already started
Description: This service starts an explicitly synchronized schedule table synchronously.
⌋ (SRS_Os_11002)
8.4.14 SyncScheduleTable
[SWS_Os_00199] ⌈
Service name: SyncScheduleTable
Syntax: StatusType SyncScheduleTable(
ScheduleTableType ScheduleTableID,
TickType Value
)
Service ID[hex]: 0x0c
Sync/Async: Synchronous
Reentrancy: Reentrant
ScheduleTableID Schedule table to be synchronized
Parameters (in):
Value The current value of the synchronization counter
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No errors
E_OS_ID (only in EXTENDED status): The ScheduleTableID
was not valid or schedule
table can not be synchronized (OsScheduleTblSyncStrategy not
set or
Return value: OsScheduleTblSyncStrategy = IMPLICIT)
E_OS_VALUE (only in EXETENDED status): The <Value> is out
of range
E_OS_STATE: The state of schedule table <ScheduleTableID>
is equal to
SCHEDULETABLE_STOPPED
Description: This service provides the schedule table with a synchronization count and start
synchronization.
⌋ (SRS_Os_11002)
8.4.15 SetScheduleTableAsync
[SWS_Os_00422] ⌈
Service name: SetScheduletableAsync
Syntax: StatusType SetScheduletableAsync(
ScheduleTableType ScheduleTableID
)
Service ID[hex]: 0x0d
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ScheduleTableID Schedule table for which status is requested
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No Error
Return value:
E_OS_ID (only in EXTENDED status): Invalid ScheduleTableID
Description: This service stops synchronization of a schedule table.
⌋ ()
8.4.16 GetScheduleTableStatus
[SWS_Os_00227] ⌈
Service name: GetScheduleTableStatus
Syntax: StatusType GetScheduleTableStatus(
ScheduleTableType ScheduleTableID,
ScheduleTableStatusRefType ScheduleStatus
)
Service ID[hex]: 0x0e
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ScheduleTableID Schedule table for which status is requested
Parameters None
(inout):
Parameters (out): ScheduleStatus Reference to ScheduleTableStatusType
StatusType E_OK: No Error
Return value:
E_OS_ID (only in EXTENDED status): Invalid ScheduleTableID
Description: This service queries the state of a schedule table (also with respect to
synchronization).
⌋ (SRS_Os_11002)
waits for the end of the current schedule table, GetScheduleTableStatus() shall
return SCHEDULETABLE_NEXT via the reference parameter <ScheduleStatus> AND
shall return E_OK. ⌋ ( )
8.4.17 IncrementCounter
[SWS_Os_00399] ⌈
Service name: IncrementCounter
Syntax: StatusType IncrementCounter(
CounterType CounterID
)
Service ID[hex]: 0x0f
Sync/Async: Synchronous, may cause rescheduling
Reentrancy: Reentrant
Parameters (in): CounterID The Counter to be incremented
Parameters None
(inout):
Parameters (out): None
Return value: StatusType E_OK: No errors
144 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
8.4.18 GetCounterValue
[SWS_Os_00383] ⌈
Service name: GetCounterValue
Syntax: StatusType GetCounterValue(
CounterType CounterID,
TickRefType Value
)
Service ID[hex]: 0x10
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): CounterID The Counter which tick value should be read
Parameters None
(inout):
Parameters (out): Value Contains the current tick value of the counter
StatusType E_OK: No errors
Return value: E_OS_ID (only in EXTENDED status): The <CounterID> was not
valid
Description: This service reads the current count value of a counter (returning either the
hardware timer ticks if counter is driven by hardware or the software ticks when
user drives counter).
145 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
⌋ (SRS_Frt_00025)
8.4.19 GetElapsedValue
[SWS_Os_00392] ⌈
Service name: GetElapsedValue
Syntax: StatusType GetElapsedValue(
CounterType CounterID,
TickRefType Value,
TickRefType ElapsedValue
)
Service ID[hex]: 0x11
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): CounterID The Counter to be read
Parameters Value in: the previously read tick value of the counter
(inout): out: the current tick value of the counter
Parameters (out): ElapsedValue The difference to the previous read value
StatusType E_OK: No errors
E_OS_ID (only in EXTENDED status): The CounterID was not
Return value: valid
E_OS_VALUE (only in EXTENDED status): The given Value was
not valid
Description: This service gets the number of ticks between the current tick value and a
previously read tick value.
⌋ (SRS_Frt_00025)
8.4.20 TerminateApplication
[SWS_Os_00258] ⌈
Service name: TerminateApplication
Syntax: StatusType TerminateApplication(
ApplicationType Application,
RestartType RestartOption
)
Service ID[hex]: 0x12
Sync/Async: Synchronous
Reentrancy: Reentrant
Application The identifier of the OS-Application to be terminated. If the caller
belongs to <Application> the call results in a self termination.
Parameters (in):
RestartOption Either RESTART for doing a restart of the OS-Application or
NO_RESTART if OS-Application shall not be restarted.
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No errors
E_OS_ID: <Application> was not valid (only in EXTENDED status)
E_OS_VALUE: <RestartOption> was neither RESTART nor
NO_RESTART (only in EXTENDED status)
Return value:
E_OS_ACCESS: The caller does not have the right to terminate
<Application> (only in EXTENDED status)
E_OS_STATE: The state of <Application> does not allow
terminating <Application>
Description: This service terminates the OS-Application to which the calling Task/Category 2
ISR/application specific error hook belongs.
⌋ ()
8.4.21 AllowAccess
[SWS_Os_00501] ⌈
Service name: AllowAccess
Syntax: StatusType AllowAccess(
void
)
Service ID[hex]: 0x13
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No errors
Return value: E_OS_STATE:The OS-Application of the caller is in the wrong
state
Description: This service sets the own state of an OS-Application from
APPLICATION_RESTARTING to APPLICATION_ACCESSIBLE.
⌋ ()
8.4.22 GetApplicationState
[SWS_Os_00499] ⌈
Service name: GetApplicationState
Syntax: StatusType GetApplicationState(
149 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
ApplicationType Application,
ApplicationStateRefType Value
)
Service ID[hex]: 0x14
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): Application The OS-Application from which the state is requested
Parameters None
(inout):
Parameters (out): Value The current state of the application
StatusType E_OK: No errors
Return value:
E_OS_ID: <Application> is not valid (only in EXTENDED status)
Description: This service returns the current state of an OS-Application.
⌋ ()
8.4.23 GetNumberOfActivatedCores
[SWS_Os_00672] ⌈
Service name: GetNumberOfActivatedCores
Syntax: uint32 GetNumberOfActivatedCores(
void
)
Service ID[hex]: 0x15
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Return value: uint32 Number of cores activated by the StartCore function (see below)
Description: The function returns the number of cores activated by the StartCore function.
This function might be a macro.
⌋ (SRS_Os_80001)
8.4.24 GetCoreID
[SWS_Os_00674] ⌈
Service name: GetCoreID
Syntax: CoreIdType GetCoreID(
void
)
Service ID[hex]: 0x16
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Return value: CoreIdType The return value is the unique ID of the core.
Description: The function returns a unique core identifier.
⌋ (SRS_Os_80001)
[SWS_Os_00675] ⌈The function GetCoreID shall return the unique logical CoreID of
the core on which the function is called. The mapping of physical cores to logical
CoreIDs is implementation specific. ⌋ (SRS_Os_80001)
8.4.25 StartCore
[SWS_Os_00676] ⌈
Service name: StartCore
Syntax: void StartCore(
CoreIdType CoreID,
StatusType* Status
)
Service ID[hex]: 0x17
Sync/Async: Synchronous
Reentrancy: Non Reentrant
Parameters (in): CoreID Core identifier
Parameters None
(inout):
Status Return value of the function in extended status:
E_OK: No Error
E_OS_ID: Core ID is invalid.
E_OS_ACCESS: The function was called after starting the OS.
Parameters (out):
E_OS_STATE: The Core is already activated.
[SWS_Os_00677] ⌈The function StartCore shall start one core that shall run under
the control of the AUTOSAR OS. ⌋ (SRS_Os_80006, SRS_Os_80026, SRS_Os_80027)
[SWS_Os_00679] ⌈If the parameter CoreIDs refers to a core that was already
started by the function StartCore the related core is ignored and E_OS_STATE
shall be returned. ⌋ (SRS_Os_80006, SRS_Os_80026, SRS_Os_80027)
[SWS_Os_00680] ⌈If the parameter CoreID refers to a core that was already
started by the function StartNonAutosarCore the related core is ignored and
E_OS_STATE shall be returned. ⌋ (SRS_Os_80006, SRS_Os_80026, SRS_Os_80027)
8.4.26 StartNonAutosarCore
[SWS_Os_00682] ⌈
Service name: StartNonAutosarCore
Syntax: void StartNonAutosarCore(
CoreIdType CoreID,
StatusType* Status
)
Service ID[hex]: 0x18
Sync/Async: Synchronous
Reentrancy: Non Reentrant
Parameters (in): CoreID Core identifier
Parameters None
(inout):
Status Return value of the function in standard status:
E_OK: No Error
E_OS_ID: Core ID is invalid.
Parameters (out): E_OS_STATE: The Core is already activated.
[SWS_Os_00684] ⌈If the parameter CoreID refers to a core that was already
started by the function StartNonAutosarCore has no effect and sets “Status” to
E_OS_STATE. ⌋ (SRS_Os_80006, SRS_Os_80026, SRS_Os_80027)
[SWS_Os_00685] ⌈If the parameter CoreID refers to an unknown core the function
StartNonAutosarCore has no effect and sets “Status” to E_OS_ID. ⌋
(SRS_Os_80006, SRS_Os_80026, SRS_Os_80027)
8.4.27 GetSpinlock
[SWS_Os_00686] ⌈
Service name: GetSpinlock
Syntax: StatusType GetSpinlock(
SpinlockIdType SpinlockId
)
Service ID[hex]: 0x19
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): SpinlockId The value refers to the spinlock instance that shall be locked.
Parameters None
(inout):
Parameters (out): None
StatusType E_OK - In standard and extended status : No Error
E_OS_ID - In extended status: The SpinlockId is invalid
E_OS_INTERFERENCE_DEADLOCK - In extended status: A TASK
tries to occupy the spinlock while the lock is already occupied by a
TASK on the same core. This would cause a deadlock.
Return value:
E_OS_NESTING_DEADLOCK - In extended status: A TASK tries to
occupy the spinlock while a TASK on the same core is holding a
different spinlock in a way that may cause a deadlock.
E_OS_ACCESS - In extended status: The spinlock cannot be
accessed.
Description: GetSpinlock tries to occupy a spin-lock variable. If the function returns, either the
lock is successfully taken or an error has occurred. The spinlock mechanism is an
active polling mechanism. The function does not cause a de-scheduling.
⌋ (SRS_Os_80021)
8.4.28 ReleaseSpinlock
[SWS_Os_00695] ⌈
Service name: ReleaseSpinlock
Syntax: StatusType ReleaseSpinlock(
SpinlockIdType SpinlockId
)
Service ID[hex]: 0x1a
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): SpinlockId The value refers to the spinlock instance that shall be locked.
Parameters None
(inout):
Parameters (out): None
StatusType E_OK - In standard and extended status: No Error
E_OS_ID - In extended status: The SpinlockId is invalid.
E_OS_STATE - In extended status: The Spinlock is not occupied by
the TASK
Return value:
E_OS_ACCESS - In extended status: The Spinlock cannot be
accessed.
E_OS_NOFUNC - In extended status: Attempt to release a spinlock
while another spinlock (or resource) has to be released before.
Description: ReleaseSpinlock releases a spinlock variable that was occupied before. Before
terminating a TASK all spinlock variables that have been occupied with
GetSpinlock() shall be released. Before calling WaitEVENT all Spinlocks shall be
154 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
released.
⌋ (SRS_Os_80021)
8.4.29 TryToGetSpinlock
[SWS_Os_00703] ⌈
Service name: TryToGetSpinlock
Syntax: StatusType TryToGetSpinlock(
SpinlockIdType SpinlockId,
TryToGetSpinlockType* Success
)
Service ID[hex]: 0x1b
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): SpinlockId The value refers to the spinlock instance that shall be locked.
Parameters None
(inout):
Parameters (out): Success Returns if the lock has been occupied or not
StatusType E_OK - In standard and extended status: No Error
E_OS_ID - In extended status: The SpinlockId is invalid.
Return value:
E_OS_INTERFERENCE_DEADLOCK - In extended status: A TASK
tries to occupy the spinlock while the lock is already occupied by a
155 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
[SWS_Os_00706] ⌈If the function TryToGetSpinlock does not return E_OK, the
OUT parameter "Success" shall be undefined. ⌋ (SRS_Os_80021)
8.4.30 ShutdownAllCores
[SWS_Os_00713] ⌈
Service name: ShutdownAllCores
Syntax: void ShutdownAllCores(
StatusType Error
)
Service ID[hex]: 0x1c
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): Error <Error> needs to be a valid error code supported by the AUTOSAR OS.
Parameters None
(inout):
Parameters (out): None
Return value: None
Description: After this service the OS on all AUTOSAR cores is shut down. Allowed at TASK
level and ISR level and also internally by the OS. The function will never return.
The function will force other cores into a shutdown.
⌋ (SRS_Os_80007)
8.4.31 ControlIdle
[SWS_Os_00769] ⌈
Service name: ControlIdle
Syntax: StatusType ControlIdle(
CoreIdType CoreID,
IdleModeType IdleMode
)
Service ID[hex]: 0x1d
Sync/Async: Synchronous
Reentrancy: Non Reentrant
CoreID selects the core which idle mode is set
Parameters (in): IdleMode the mode which shall be performed during idle
time
Parameters None
(inout):
Parameters (out): None
StatusType E_OK: No Error
Return value: E_OS_ID (only EXTENDED status): Invalid core and/or invalid
idleMode
Description: This API allows the caller to select the idle mode action which is performed during
idle time of the OS (e.g. if no Task/ISR is active). It can be used to implement
157 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
energy savings. The real idle modes are hardware dependent and not
standardized. The default idle mode on each core is IDLE_NO_HALT.
⌋ ()
8.4.32 ReadPeripheralX
[SWS_Os_91013] ⌈
Service name: ReadPeripheral8
Syntax: StatusType ReadPeripheral8(
AreaIdType Area,
const uint8* Address,
uint8* ReadValue
)
Service ID[hex]: 0x28
Sync/Async: Synchronous
Reentrancy: Reentrant
Area hardware peripheral area reference
Parameters (in):
Address memory address
Parameters None
(inout):
Parameters (out): ReadValue content of the given memory location (<Address>)
StatusType E_OK No error
E_OS_ID Area id is out of range (EXTENDED status)
E_OS_VALUE Address does not belong to given Area (EXTENDED
status)
Return value:
E_OS_CALLEVEL Wrong call context of the API function (EXTENDED
status)
E_OS_ACCESS The calling task or ISR is not allowed to access the
given
Description: This service returns the content of a given memory location (<Address>).
⌋ (SRS_Os_11005)
[SWS_Os_91015] ⌈
Service name: ReadPeripheral16
Syntax: StatusType ReadPeripheral16(
AreaIdType Area,
const uint16* Address,
uint16* ReadValue
)
158 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
[SWS_Os_91014] ⌈
Service name: ReadPeripheral32
Syntax: StatusType ReadPeripheral32(
AreaIdType Area,
const uint32* Address,
uint32* ReadValue
)
Service ID[hex]: 0x2b
Sync/Async: Synchronous
Reentrancy: Reentrant
Area hardware peripheral area reference
Parameters (in):
Address memory address
Parameters None
(inout):
Parameters (out): ReadValue content of the given memory location (<Address>)
StatusType E_OK No error
E_OS_ID Area id is out of range (EXTENDED status)
E_OS_VALUE Address does not belong to given Area (EXTENDED
status)
Return value:
E_OS_CALLEVEL Wrong call context of the API function (EXTENDED
status)
E_OS_ACCESS The calling task or ISR is not allowed to access the
given
Description: This service returns the content of a given memory location (<Address>).
⌋ (SRS_Os_11005)
8.4.33 WritePeripheralX
[SWS_Os_91010] ⌈
Service name: WritePeripheral8
Syntax: StatusType WritePeripheral8(
AreaIdType Area,
uint8* Address,
uint8 WriteValue
)
[SWS_Os_91012] ⌈
Service name: WritePeripheral16
Syntax: StatusType WritePeripheral16(
AreaIdType Area,
uint16* Address,
uint16 WriteValue
)
Service ID[hex]: 0x2c
Sync/Async: Synchronous
Reentrancy: Reentrant
Area hardware peripheral area reference
Parameters (in):
Address memory address
Parameters None
(inout):
Parameters (out): WriteValue value to be written at the memory address
StatusType E_OK No error
E_OS_ID Area id is out of range (EXTENDED status)
E_OS_VALUE Address does not belong to given Area (EXTENDED
status)
Return value:
E_OS_CALLEVEL Wrong call context of the API function (EXTENDED
status)
E_OS_ACCESS The calling task or ISR is not allowed to access the
given
Description: This service writes the <value> to a given memory location (<memory address>).
⌋ (SRS_Os_11005)
[SWS_Os_91011] ⌈
Service name: WritePeripheral32
Syntax: StatusType WritePeripheral32(
AreaIdType Area,
uint32* Address,
uint32 WriteValue
)
Service ID[hex]: 0x2d
Sync/Async: Synchronous
Reentrancy: Reentrant
Area hardware peripheral area reference
Parameters (in):
Address memory address
Parameters None
(inout):
Parameters (out): WriteValue content of the given memory location (<Address>)
StatusType E_OK No error
E_OS_ID Area id is out of range (EXTENDED status)
E_OS_VALUE Address does not belong to given Area (EXTENDED
status)
Return value:
E_OS_CALLEVEL Wrong call context of the API function (EXTENDED
status)
E_OS_ACCESS The calling task or ISR is not allowed to access the
given
Description: This service writes the <value> to a given memory location (<memory address>).
⌋ (SRS_Os_11005)
8.4.34 ModifyPeripheralX
[SWS_Os_91016] ⌈
Service name: ModifyPeripheral8
Syntax: StatusType ModifyPeripheral8(
AreaIdType Area,
uint8* Address,
uint8 Clearmask,
uint8 Setmask
)
Service ID[hex]: 0x2e
Sync/Async: Synchronous
Reentrancy: Reentrant
Area hardware peripheral area reference
Address memory address
Parameters (in):
Clearmask memory address will be modified by an bit-AND
Setmask memory address will be modified by an bit-OR
Parameters None
(inout):
Parameters (out): None
StatusType E_OK No error
E_OS_ID Area id is out of range (EXTENDED status)
E_OS_VALUE Address does not belong to given Area
(EXTENDED status)
Return value:
E_OS_CALLEVEL Wrong call context of the API function
(EXTENDED status)
E_OS_ACCESS The calling task or ISR is not allowed to access
the given
Description: This service modifies a given memory location (<memory address>) with the
formula: *<Address> = ((*<Address> & <clearmask>) | <setmask>)
⌋ (SRS_Os_11005)
[SWS_Os_91018] ⌈
Service name: ModifyPeripheral16
Syntax: StatusType ModifyPeripheral16(
AreaIdType Area,
uint16* Address,
uint16 Clearmask,
161 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
uint16 Setmask
)
Service ID[hex]: 0x2d
Sync/Async: Synchronous
Reentrancy: Reentrant
Area hardware peripheral area reference
Address memory address
Parameters (in):
Clearmask memory address will be modified by an bit-AND
Setmask memory address will be modified by an bit-OR
Parameters None
(inout):
Parameters (out): None
StatusType E_OK No error
E_OS_ID Area id is out of range (EXTENDED status)
E_OS_VALUE Address does not belong to given Area
(EXTENDED status)
Return value:
E_OS_CALLEVEL Wrong call context of the API function
(EXTENDED status)
E_OS_ACCESS The calling task or ISR is not allowed to access
the given
Description: This service modifies a given memory location (<memory address>) with the
formula: *<Address> = ((*<Address> & <clearmask>) | <setmask>)
⌋ (SRS_Os_11005)
[SWS_Os_91017] ⌈
Service name: ModifyPeripheral32
Syntax: StatusType ModifyPeripheral32(
AreaIdType Area,
uint32* Address,
uint32 Clearmask,
uint32 Setmask
)
Service ID[hex]: 0x2f
Sync/Async: Synchronous
Reentrancy: Reentrant
Area hardware peripheral area reference
Address memory address
Parameters (in):
Clearmask memory address will be modified by an bit-AND
Setmask memory address will be modified by an bit-OR
Parameters None
(inout):
Parameters (out): None
StatusType E_OK No error
E_OS_ID Area id is out of range (EXTENDED status)
E_OS_VALUE Address does not belong to given Area
(EXTENDED status)
Return value:
E_OS_CALLEVEL Wrong call context of the API function
(EXTENDED status)
E_OS_ACCESS The calling task or ISR is not allowed to access
the given
Description: This service modifies a given memory location (<memory address>) with the
formula: *<Address> = ((*<Address> & <clearmask>) | <setmask>)
⌋ (SRS_Os_11005)
8.4.35 EnableInterruptSource
[SWS_Os_91020] ⌈
Service name: EnableInterruptSource
Syntax: StatusType EnableInterruptSource(
ISRType ISRID,
boolean ClearPending
)
Service ID[hex]: 0x31
Sync/Async: Synchronous
Reentrancy: Reentrant
ISRID The ID of a category 2 ISR.
Parameters (in): ClearPending Defines whether the pending flag shall be cleared (TRUE) or not
(FALSE).
Parameters None
(inout):
Parameters (out): None
StatusType E_OK No error.
E_OS_ID ISRID is not a valid category 2 ISR identifier (EXTENDED
status)
Return value: E_OS_CALLEVEL Wrong call context of the API function
(EXTENDED status)
E_OS_ACCESS The calling application is not the owner of the ISR
passed in ISRID (Service Protection)
Description: Enables the interrupt source by modifying the interrupt controller registers.
Additionally it may clear the interrupt pending flag
⌋ (SRS_Os_11011)
8.4.36 DisableInterruptSource
[SWS_Os_91019] ⌈
Service name: DisableInterruptSource
Syntax: StatusType DisableInterruptSource(
ISRType ISRID
)
Service ID[hex]: 0x30
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ISRID The ID of a category 2 ISR.
Parameters None
(inout):
Parameters (out): None
StatusType E_OK No error.
E_OS_ID ISRID is not a valid category 2 ISR identifier (EXTENDED
status)
Return value: E_OS_CALLEVEL Wrong call context of the API function (EXTENDED
status)
E_OS_ACCESS The calling application is not the owner of the ISR
passed in ISRID (Service Protection)
Description: Disables the interrupt source by modifying the interrupt controller registers.
⌋ (SRS_Os_11011)
8.4.37 ClearPendingInterrupt
[SWS_Os_91021] ⌈
Service name: ClearPendingInterrupt
Syntax: StatusType ClearPendingInterrupt(
ISRType ISRID
)
Service ID[hex]: 0x32
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ISRID The ID of a category 2 ISR.
Parameters None
(inout):
Parameters (out): None
StatusType E_OK No error.
E_OS_ID ISRID is not a valid category 2 ISR identifier (EXTENDED
status)
Return value: E_OS_CALLEVEL Wrong call context of the API function (EXTENDED
status)
E_OS_ACCESS The calling application is not the owner of the ISR
passed in ISRID (Service Protection)
Description: Clears the interrupt pending flag by modifying the interrupt controller registers.
⌋ (SRS_Os_11011)
8.5 IOC
8.5.1 Imported types
In this chapter all types included from the following files are listed:
None
8.5.3 Constants
8.5.4.1 IocSend/IocWrite
The IocWrite API call is generated for "data" (unqueued) semantics and the
IocSend API call is generated for "events" (queued) semantics.
[SWS_Os_00718] ⌈
Service name: IocSend_<IocId>[_<SenderId>]
Syntax: Std_ReturnType IocSend_<IocId>[_<SenderId>](
<Data> IN,
[uint16 numberOfBytesIN]
)
Service ID[hex]: 0x1e
Sync/Async: Asynchronous
Reentrancy: This function is generated individually for each sender. The individual function is
not reentrant (if called from different runnable entities that belong to the same
sender), but different functions can be called in parallel.
IN Data value to be sent over a communication identified by the
<IocId>. The parameter will be passed by value for primitive
data elements and by reference for all other types.
⌋ (SRS_Os_80020)
[SWS_Os_91003] ⌈
Service name: IocWrite_<IocId>[_<SenderId>]
Syntax: Std_ReturnType IocWrite_<IocId>[_<SenderId>](
<Data> IN,
[uint16 numberOfBytesIN]
)
Service ID[hex]: 0x1f
Sync/Async: Asynhronous
Reentrancy: This function is generated individually for each sender. The individual function is
not reentrant (if called from different runnable entities that belong to the same
sender), but different functions can be called in parallel.
IN Data value to be sent over a communication identified by the
<IocId>. The parameter will be passed by value for primitive
data elements and by reference for all other types.
General:
[SWS_Os_00719] ⌈IocSend/IocWrite is asynchronous in that way it shall not
have to wait for the reception of the data on the receiving side to return from
execution. ⌋ (SRS_Os_80020)
[SWS_Os_00720] ⌈The IocSend/IocWrite function shall not return until the data
given in parameter have been completely physically sent over the communication
medium.
Parameters:
[SWS_Os_00723] ⌈
The IN <Data> parameter of the IocSend/IocWrite function shall be passed
by value for primitive data types, as an pointer to the array base type for arrays and
by reference for all other types. ⌋ (SRS_Os_80020)
[SWS_Os_00724] ⌈
For data passed as an pointer to the array base type or by reference, the
IocSend/IocWrite function shall guarantee upon return that the parameter is safe
for re-use.⌋ (SRS_Os_80020)
Returned values:
[SWS_Os_00725] ⌈The IocSend/IocWrite function shall return IOC_E_OK if the
data was passed successfully to the communication service. ⌋ (SRS_Os_80020)
[SWS_Os_00726] ⌈In case of “event” semantic the IocSend function shall return
IOC_E_LIMIT if an IOC internal transmission buffer became full (Case: Receiver is
slower than sender or/and configured internal IOC buffer size is too small).
If this error occurs the IOC internal buffer could not be filled with the parameter. In
that case this error shall produce an IOC_E_LOST_DATA Overlayed Error on the
receiver side at the next data reception (s. SWS_Os_00745). ⌋ (SRS_Os_80020)
Internal structures:
[SWS_Os_00727] ⌈In case of “event” semantic the IOC shall configure its internal
transmission buffer size with the value of the attribute OsIocBufferLength. ⌋
(SRS_Os_80020)
8.5.4.2 IocSendGroup/IocWriteGroup
The IocWriteGroup API call is generated for "data" (unqueued) semantics and the
IocSendGroup API call is generated for "events" (queued) semantics.
[SWS_Os_00728] ⌈
Service name: IocSendGroup_<IocId>
Syntax: Std_ReturnType IocSendGroup_<IocId>(
<Data1> IN1,
[uint16 numberOfBytesIN1,]
<Data2> IN2,
[uint16 numberOfBytesIN2,]
...
)
Service ID[hex]: 0x20
Sync/Async: Asynchronous
Reentrancy: This function is generated individually for each sender. The individual function is
not reentrant (if called from different runnable entities that belong to the same
sender), but different functions can be called in parallel.
IN1 List of parameters with data values to be sent over a
communication identified by the <IocId>. The parameters will
be passed by value for simple data elements and by reference
for all other types.
Example:
This API involves a group of data elements which values are specified in
parameter.
[SWS_Os_91004] ⌈
Service name: IocWriteGroup_<IocId>
Syntax: Std_ReturnType IocWriteGroup_<IocId>(
<Data1> IN1,
[uint16 numberOfBytesIN1,]
<Data2> IN2,
[uint16 numberOfBytesIN2,]
...
)
Service ID[hex]: 0x21
Sync/Async: Asynchronous
Reentrancy: This function is generated individually for each sender. The individual function is
not reentrant (if called from different runnable entities that belong to the same
sender), but different functions can be called in parallel.
IN1 List of parameters with data values to be sent over a
communication identified by the <IocId>. The parameters will
be passed by value for simple data elements and by reference
for all other types.
Example:
This API involves a group of data elements which values are specified in
parameter.
General:
[SWS_Os_00729] ⌈IocSendGroup/IocWriteGroup is asynchronous in that way
it shall not have to wait for the reception of the data on the receiving side to return
from execution. ⌋ (SRS_Os_80020)
Parameters:
[SWS_Os_00733] ⌈
The IN <DataN> parameters of the IocSendGroup/IocWriteGroup function shall
be passed by values for primitive data types, as pointer to the array base type for
arrays and by references for all other types.
⌋ (SRS_Os_80020)
[SWS_Os_00734] ⌈
For data passed as an pointer to the array base type or by reference, the
IocSendGroup/IocWriteGroup function shall guarantee upon return that the
parameter is safe for re-use.
⌋ (SRS_Os_80020)
Returned values:
[SWS_Os_00735] ⌈The IocSendGroup/IocWriteGroup function shall return
IOC_E_OK if the data was passed successfully to the communication service. ⌋
(SRS_Os_80020)
If this error occurs the IOC Internal buffer could not be filled with the parameter. In
that case this error produces an IOC_E_LOST_DATA Overlayed Error on the
receiver side at the next data reception. ⌋ (SRS_Os_80020)
Internal structures:
[SWS_Os_00737] ⌈In case of “event” semantic the IOC shall configure its internal
transmission buffer size with the value of the attribute OsIocBufferLength. ⌋
(SRS_Os_80020)
8.5.4.3 IocReceive/IocRead
The IocRead API call is generated for "data" and the IocReceive API call is
generated for "events".
[SWS_Os_00738] ⌈
Service name: IocReceive_<IocId>
Syntax: Std_ReturnType IocReceive_<IocId>(
<Data> OUT,
[uint16* numberOfBytesOUT]
)
Service ID[hex]: 0x22
Sync/Async: Synchronous
Reentrancy: This function is generated individually for each receiver. The individual function is
not reentrant (if called from different runnable entities that belong to the same
receiver), but different functions can be called in parallel.
Parameters (in): None
Parameters None
(inout):
OUT Data reference to be filled with the received data element.
Parameters (out): numberOfBytesOUT (optional) data reference to be filled with the length of the
received data element in bytes.
Std_ReturnType IOC_E_OK: Data was received successfully
[SWS_Os_91005] ⌈
Service name: IocRead_<IocId>
Syntax: Std_ReturnType IocRead_<IocId>(
<Data> OUT,
172 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
[uint16* numberOfBytesOUT]
)
Service ID[hex]: 0x23
Sync/Async: Synchronous
Reentrancy: This function is generated individually for each receiver. The individual function is
not reentrant (if called from different runnable entities that belong to the same
receiver), but different functions can be called in parallel.
Parameters (in): None
Parameters None
(inout):
OUT Data reference to be filled with the received data
element.
Parameters (out):
numberOfBytesOUT (optional) data reference to be filled with the length of
the received data element in bytes.
Return value: Std_ReturnType IOC_E_OK: Data was received successfully
Description: Performs an "explicit" sender-receiver reception of data elements with "data"
semantic for a unidirectional communication between OS-Applications located on
the same or on different cores.
General:
[SWS_Os_00739] ⌈A successful call to the IocReceive/IocRead function
indicates that data has been received successfully in the OUT <Data> given in
parameter.
Parameters:
[SWS_Os_00741] ⌈In case of “data” semantic the IocRead function shall always be
able to deliver the last available datum. In case of senders from different cores, the
precision of the order might be limited by the hardware and implementation. ⌋
(SRS_Os_80020)
Returned values:
[SWS_Os_00743] ⌈The IocReceive/IocRead function shall return IOC_E_OK if
the data was received successfully in the OUT <Data> parameter. ⌋ (SRS_Os_80020)
8.5.4.4 IocReceiveGroup/IocReadGroup
The IocReadGroup API call is generated for "data" and the IocReceiveGroup
API call is generated for "events".
[SWS_Os_00746] ⌈
Service name: IocReceiveGroup_<IocId>
Syntax: Std_ReturnType IocReceiveGroup_<IocId>(
<Data1> OUT1,
[uint16* numberOfBytesOUT1,]
<Data2> OUT2,
[uint16* numberOfBytesOUT2,]
...
)
Service ID[hex]: 0x24
Sync/Async: Synchronous
Reentrancy: This function is generated individually for each receiver. The individual function is
not reentrant (if called from different runnable entities that belong to the same
receiver), but different functions can be called in parallel.
Parameters (in): None
Parameters None
(inout):
OUT1 List of data references to be filled with the received data
elements. The specified order of the parameter shall match
to the specified order in the corresponding send function.
numberOfBytesOUT1 (optional) data reference to be filled with the length of the
Parameters (out): received data element (OUT1) in bytes.
OUT2 --
numberOfBytesOUT2 --
-- --
Std_ReturnType IOC_E_OK: Data was received successfully
This API involves a group of data elements which values are specified in
parameter.
[SWS_Os_91006] ⌈
Service name: IocReadGroup_<IocId>
Syntax: Std_ReturnType IocReadGroup_<IocId>(
<Data1> OUT1,
[uint16* numberOfBytesOUT1,]
<Data2> OUT2,
[uint16* numberOfBytesOUT2,]
...
)
Service ID[hex]: 0x25
Sync/Async: Synchronous
Reentrancy: This function is generated individually for each receiver. The individual function is
not reentrant (if called from different runnable entities that belong to the same
receiver), but different functions can be called in parallel.
Parameters (in): None
Parameters None
(inout):
OUT1 List of data references to be filled with the received data
elements. The specified order of the parameter shall match
to the specified order in the corresponding send function.
numberOfBytesOUT1 (optional) data reference to be filled with the length of the
Parameters (out): received data element (OUT1) in bytes.
OUT2 --
numberOfBytesOUT2 --
-- --
Return value: Std_ReturnType IOC_E_OK: Data was received successfully
Description: Performs an "explicit" sender-receiver transmission of data elements with a "data"
semantic for a unidirectional 1:1 communication between OS-Applications located
on the same or on different cores.
This API involves a group of data elements which values are specified in
parameter.
General:
[SWS_Os_00747] ⌈A successful call to the IocReceiveGroup/IocReadGroup
function indicates that data has been received successfully in the given parameters.
Parameters:
[SWS_Os_00749] ⌈In case of “data” semantic the IocReadGroup function shall
always be able to deliver the last available datum. ⌋ (SRS_Os_80020)
Returned values:
[SWS_Os_00751] ⌈The IocReceiveGroup/IocReadGroup function shall return
IOC_E_OK if the data was received successfully in the list of references given in
parameter. ⌋ (SRS_Os_80020)
8.5.4.5 IocEmptyQueue
[SWS_Os_00754] ⌈
Service name: IocEmptyQueue_<IocId>
Syntax: Std_ReturnType IocEmptyQueue_<IocId>(
void
)
Service ID[hex]: 0x26
Sync/Async: Synchronous
Reentrancy: Non reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Std_ReturnType IOC_E_OK: Content of the queue was successfully
Return value:
deleted
Description: In case of queued communication identified by the <IocId> in the function name,
176 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
General:
[SWS_Os_00755] ⌈The function IocEmptyQueue_<IocId> shall be present for all
IOC elements with queued semantics. ⌋ (SRS_Os_80020)
8.6.2.1 ReceiverPullCB
[SWS_Os_00757] ⌈
Service name: <ReceiverPullCB>
Syntax: void <ReceiverPullCB>(
void
)
Service ID[hex]: --
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Return value: None
Description: This callback function can be configured for the receiver of a communication. If
configured, IOC calls this callback on the receiving core for each data reception.
<ReceiverPullCB> is the callback function name configured by the receiver in the
OsIocReceiverPullCB attribute to be called on data reception."
⌋ (SRS_Os_80020)
[SWS_Os_00759] ⌈The name of the callback shall be unique over the micro
controller. For this purpose the following example can be considered as orientation
for the IOC user:
Example: Rte_IocReceiveCB_<IocId>⌋ (SRS_Os_80020)
Note: This means that such a callback cannot be reused by another OsApplication.
The owner of the <ReceiverPullCB> function shall pay attention that the execution
time of the function shall not last too long. It shall be possible to call this function from
an IOC-ISR.
[SWS_Os_00538] ⌈
Service name: ProtectionHook
Syntax: ProtectionReturnType ProtectionHook(
StatusType Fatalerror
)
Service ID[hex]: --
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): Fatalerror The error which caused the call to the protection hook
Parameters None
(inout):
Parameters (out): None
ProtectionReturnType PRO_IGNORE
PRO_TERMINATETASKISR
PRO_TERMINATEAPPL
Return value: PRO_TERMINATEAPPL_RESTART
PRO_SHUTDOWN
The return value defines the action the OS shall take
after the protection hook.
Description: The protection hook is always called if a serious error occurs. E.g. exceeding the
worst case execution time or violating against the memory protection.
⌋ ()
Depending on the return value the Operating System module will either:
forcibly terminate the Task/Category 2 ISR which causes the problem OR
forcibly terminate the OS-Application the Task/Category 2 ISR belong
(optional with restart) OR
shutdown the system OR
do nothing
(see 7.8.2)
[SWS_Os_00539] ⌈
Service name: StartupHook_<App>
Syntax: void StartupHook_<App>(
void
)
Service ID[hex]: --
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Return value: None
Description: The application specific startup hook is called during the start of the OS (after the
user has started the OS via StartOS()).
⌋ ()
[SWS_Os_00540] ⌈
Service name: ErrorHook_<App>
Syntax: void ErrorHook_<App>(
StatusType Error
)
Service ID[hex]: --
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): Error The error which caused the call to the error hook
Parameters None
(inout):
Parameters (out): None
Return value: None
Description: The application specific error hook is called whenever a Task or Category 2 ISR
which belongs to the OS-Application causes an error.
⌋ ()
[SWS_Os_00541] ⌈
Service name: ShutdownHook_<App>
Syntax: void ShutdownHook_<App>(
StatusType Fatalerror
)
Service ID[hex]: --
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): Fatalerror The error which caused the action to shut down the operating system.
Parameters None
(inout):
Parameters (out): None
Return value: None
Description: The application specific shutdown hook is called whenever the system starts the
shut down of itself.
⌋ ()
[] ⌈
Name OsService
Description --
Type CounterType
Port Defined Argument Value(s)
Value {ecuc(Os/OsCounter)}
Variation --
⌋ ()
8.8.2 Client-Server-Interfaces
8.8.2.1 Os_Service
[SWS_Os_00560] ⌈
Name OsService_{Counter}
Comment --
IsService true
({ecuc(Os/OsCounter/OsSecondsPerTick)} != NULL)
Variation
Counter = {ecuc(Os/OsCounter.SHORT-NAME)}
0 E_OK
1 E_OS_ACCESS
7 E_OS_STATE
8 E_OS_VALUE
Operations
GetCounterValue
This service reads the current count value of a counter (returning either the hardware
Comments timer ticks if counter is driven by hardware or the software ticks when user drives
counter).
Variation --
Type TimeInMicrosecondsType
Parameters Value
Variation --
Direction OUT
GetElapsedValue
This service gets the number of ticks between the current tick value and a previously
Comments
read tick value.
Variation --
Type TimeInMicrosecondsType
Value
Variation --
Direction INOUT
Parameters
Comment The difference to the previous read value
Type TimeInMicrosecondsType
ElapsedValue
Variation --
Direction OUT
[SWS_Os_00794] ⌈
Name TimeInMicrosecondsType
Kind Type
Description --
Variation --
⌋ ()
[SWS_Os_00786] ⌈
Name CounterType
Kind Type
Variation --
⌋ ()
9 Sequence diagrams
sd Interactions
CallTrustedFunction(FunID,FunParPtr)
system call
alt Check permission dispatcher
[denied]
E_OS_SERVICEID
[accepted]
<trusted function>
<CheckAccess>
<Access Information>
E_OK
<return value>
sd Interactions
OS-Appl. operating
<App> system
alt
<system service> which returns
[condition]
a value of type StatusType
alt
ErrorHook_<App> (<Error>)
StatusType value
The above sequence chart shows the sequence of error hook calls in case a service
does not return with E_OK. Note that in this case the general error hook and the OS-
Application specific error hook are called.
sd Interactions
break «Exception»
[protection error]
ProtectionHook(Fatalerror)
alt return
[PRO_TERMINATETASKISR]
«forced termination of Task/ISR»
[PRO_TERMINATEAPPL]
«forced termination of
OS-Application»
[PRO_TERMINATEAPPL_RESTART]
«forced termination of OS-
Application»
ActivateTask(RESTARTTASK)
[PRO_IGNORE]
Ignore Exception
[PRO_SHUTDOWN]
ShutdownOS
The sequence shows the flow of control if a protection error occurs. Depending on
the return values of the ProtectionHook, either the faulty Task/ISR is forcibly
terminated or the OS-Application is forcibly terminated or the system is shut down. If
the action is to terminate the faulty OS-Application an option is to start afterwards the
restart task, which can do a cleanup, etc.
sd Interactions
StartOS(<Mode>)
Initial Startup
alt
StartupHook
StartupHook_<App>
Normal Operation
The above sequence shows the flow of control during the startup of the OS. Like in
OSEK OS the user calls the StartOS() service to start the OS. During the startup
the startup hooks are called in the above order. The rest of the startup sequence is
identical to the defined behaviour of OSEK OS.
sd Interactions
Shutdow n
alt
ShutdownHook_<App>(<Error>)
ShutdownHook(<Error>)
Terminate Terminate
The figure 11 shows a sequence of successful and failure cases in the interaction
between the IOC and the RTE in case of LastIstBest communication (“data”
semantic).
sd Ioc LastIsBest
Rte_Write_<p>_<o>(Std_ReturnType,
Rte_Instance, void)
IocWrite_<IocId>[_<SenderId>](<Data>,
Std_ReturnType)
:IOC_E_OK The RTE buffer is copied
:RTE_E_OK into an IOC internal buffer.
Rte_Read_<p>_<o>(Rte_Instance,
void*)
IocRead_<IocId>(<Data>*,
The IOC reception buffer is Std_ReturnType)
:IOC_E_OK
copied into the buffer of the
receiver application. :RTE_E_OK
The figure 12 shows the interaction between IOC and RTE with a focus on the
congestion control for a queued communication.
The defined communication has no callback functionality for data reception, has an
internal buffer size of 2 data elements, no waitpoints are defined and the implicated
OS-Applications are located on different cores.
Rte_Send_<p>_<o>(Rte_Instance,
void)
IocSend_<IocId>[_<SenderId>](<Data>,
Std_ReturnType)
:IOC_E_OK The RTE buffer is copied into
:RTE_E_OK IOC internal buffer.
Rte_Send_<p>_<o>(Rte_Instance,
void)
IocSend_<IocId>[_<SenderId>](<Data>,
Std_ReturnType)
:IOC_E_OK
:RTE_E_OK
Rte_Send_<p>_<o>(Rte_Instance,
void)
IocSend_<IocId>[_<SenderId>](<Data>,
Std_ReturnType) The IOC internal queue gets
:IOC_E_LIMIT full, last send request is
:RTE_E_LIMIT rejected.
Rte_Receive_<p>_<o>(Rte_Instance,
void*)
IocReceive_<IocId>(<Data>*,
The first queue entry is delivered to
Std_ReturnType)
the receiver application. An
overlayed error is delivered on the :IOC_E_OK and IOC_E_LOST_DATA
receiver side to inform that the
:RTE_E_OK and RTE_E_LOST_DATA
receiver is too slow.
Rte_Receive_<p>_<o>(Rte_Instance,
void*)
IocReceive_<IocId>(<Data>*,
Std_ReturnType)
:IOC_E_OK
:RTE_E_OK
Rte_Receive_<p>_<o>(Rte_Instance,
IocReceive_<IocId>(<Data>*, void*)
Std_ReturnType)
:IOC_E_NO_DATA
:RTE_E_NO_DATA
The figure 13 shows the interaction between IOC and RTE in case of a queued
communication with an activated callback functionality. The RTE might handle
notification internally and might therefore not provide any callback functions, but a
similar scenario will occur in case of communication between CDDs on different
cores. The receiving CDD will provide the callback function in this case.
Rte_Send_<p>_<o>(Rte_Instance,
void)
IocSend_<IocId>[_<SenderId>](<Data>,
Std_ReturnType) Inter core notification (e.g. IRQ)
:IOC_E_OK
:RTE_E_OK
RTE_IocPullCB_<IocId>()
In case of N:1 communication the RTE stores
incoming data from different senders in an IocReceive_<IocId>(<Data>*,
internal buffer (on same or different cores) Std_ReturnType)
:IOC_E_OK
IocReceive_<IocId>(<Data>*,
It is recommended to empty the IOC internal
Std_ReturnType)
queues within the pull callback function. :IOC_E_NO_DATA
:RTE_E_OK
Rte_Receive_<p>_<o>(Rte_Instance,
void*)
:RTE_E_OK
10 Configuration Specification
In general, this chapter defines configuration parameters and their clustering into
containers. In order to support the specification Chapter 10.1 describes
fundamentals. It also specifies a template (table) you shall use for the parameter
specification.
Chapter 10.2 specifies the structure (containers) and the parameters of the module
Os.
For better readability OIL names of the 2.1 OS specification are given in curly braces
in the namefield of configuration parameters.
10.2.1 Os
Included Containers
Container Name Multiplicity Scope / Dependency
An OsAlarm may be used to asynchronously inform or activate
OsAlarm 0..* a specific task. It is possible to start alarms automatically at
system start-up depending on the application mode.
OsAppMode 1..* OsAppMode is the object used to define ISO 17356-3
193 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
10.2.2 OsAlarmSetEvent
No Included Containers
10.2.3 OsAlarm
Included Containers
Container Name Multiplicity Scope / Dependency
This container defines which type of notification is used when
OsAlarmAction 1
the alarm expires.
If present this container defines if an alarm is started
OsAlarmAutostart 0..1 automatically at system start-up depending on the application
mode.
10.2.4 OsAlarmAction
Container Choices
Container Name Multiplicity Scope / Dependency
OsAlarmActivateTask 0..1 This container specifies the parameters to activate a task.
This container specifies the parameters to call a callback OS
OsAlarmCallback 0..1
alarm action.
This container specifies the parameters to increment a
OsAlarmIncrementCounter 0..1
counter.
OsAlarmSetEvent 0..1 This container specifies the parameters to set an event
10.2.5 OsAlarmActivateTask
No Included Containers
10.2.6 OsAlarmAutostart
No Included Containers
10.2.7 OsAlarmCallback
No Included Containers
10.2.8 OsAlarmIncrementCounter
No Included Containers
10.2.9 OsApplication
Post-Build Variant
false
Multiplicity
Post-Build Variant Value false
Multiplicity ConfigurationPre-compile time X All Variants
Class Link time --
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: ECU
Multiplicity
Post-Build Variant Value false
Multiplicity ConfigurationPre-compile time X All Variants
Class Link time --
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: ECU
dependency: Required for scalability class 3 and 4.
Included Containers
Container Name Multiplicity Scope / Dependency
OsApplicationHooks 1 Container to structure the OS-Application-specific hooks
OsApplicationTrustedFunctio Container to structure the configuration parameters of trusted
0..*
n functions
10.2.10 OsApplicationHooks
No Included Containers
10.2.11 OsApplicationTrustedFunction
regularExpression --
Post-Build Variant Value false
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: ECU
dependency: Required for scalability class 3 and 4 and in trusted OS-
Applications.
No Included Containers
10.2.12 OsAppMode
No Included Containers
10.2.13 OsCounter
Range [0 .. INF]
Default value --
Post-Build Variant
false
Multiplicity
Post-Build Variant Value false
Multiplicity ConfigurationPre-compile time X All Variants
Class Link time --
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: ECU
Included Containers
Container Name Multiplicity Scope / Dependency
This Container contains the information who will drive the
counter.
This configuration is only valid if the counter has
OsCounterType set to HARDWARE.
10.2.14 OsEvent
No Included Containers
10.2.15 OsDriver
If the container does not exist (multiplicity=0) the timer is managed by the
OS internally (OSINTERNAL).
Description
If the container exists the OS can use the GPT interface to manage the
timer. The user have to supply the GPT channel.
If the counter is driven by some other (external to the OS) source (like a
TPU for example) this must be described as a vendor specific extension.
Configuration Parameters
No Included Containers
10.2.16 OsHooks
Default value --
Post-Build Variant Value false
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
No Included Containers
10.2.17 OsIsr
Included Containers
Container Name Multiplicity Scope / Dependency
This container contains all parameters which are related to
timing protection
OsIsrTimingProtection 0..1 If the container exists, the timing protection is used for this
interrupt. If the container does not exist, the interrupt is not
supervised regarding timing violations.
10.2.18 OsIsrResourceLock
No Included Containers
10.2.19 OsIsrTimingProtection
Post-build time --
Scope / Dependency scope: ECU
dependency: Required for scalability class 2 and 4
Included Containers
Container Name Multiplicity Scope / Dependency
This container contains a list of times the interrupt uses
OsIsrResourceLock 0..*
resources.
10.2.20 OsOS
Post-Build Variant
false
Value
Value Pre-compile time X All Variants
Configuration Link time --
Class Post-build time --
Scope / scope: ECU
Dependency
Included Containers
Container Name Multiplicity Scope / Dependency
OsHooks 1 Container to structure all hooks belonging to the OS
10.2.21 OsPeripheralArea
Link time --
Post-build time --
Scope / Dependency scope: local
No Included Containers
10.2.22 OsResource
No Included Containers
219 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
10.2.23 OsScheduleTable
Included Containers
Container Name Multiplicity Scope / Dependency
This container specifies if and how the schedule table is
started on startup of the Operating System. The options to
OsScheduleTableAutostart 0..1
start a schedule table correspond to the API calls to start
schedule tables during runtime.
The point on a Schedule Table at which the OS activates tasks
OsScheduleTableExpiryPoint 1..*
and/or sets events
This container specifies the synchronization parameters of the
OsScheduleTableSync 0..1
schedule table.
10.2.24 OsScheduleTableAutostart
No Included Containers
10.2.25 OsScheduleTableEventSetting
Configuration Parameters
No Included Containers
10.2.26 OsScheduleTableExpiryPoint
Included Containers
Container Name Multiplicity Scope / Dependency
OsScheduleTableEventSetting 0..* Event that is triggered by that schedule table.
223 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
10.2.27 OsScheduleTableTaskActivation
No Included Containers
10.2.28 OsScheduleTblAdjustableExpPoint
Multiplicity 1
Type EcucIntegerParamDef
Range 0 ..
18446744073709551615
Default value --
Post-Build Variant Value false
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
No Included Containers
10.2.29 OsScheduleTableSync
required.
NONE No support for synchronisation.
Default value NONE
Post-Build Variant
false
Value
Value Pre-compile time X All Variants
Configuration Link time --
Class Post-build time --
Scope / scope: ECU
Dependency
No Included Containers
10.2.30 OsSpinlock
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
No Included Containers
10.2.31 OsTask
Included Containers
Container Name Multiplicity Scope / Dependency
This container determines whether the task is activated during
the system start-up procedure or not for some specific
application modes.
OsTaskAutostart 0..1
If the task shall be activated during the system start-up, this
container is present and holds the references to the application
modes in which the task is auto-started.
OsTaskTimingProtection 0..1 This container contains all parameters regarding timing
229 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
10.2.32 OsTaskAutostart
No Included Containers
10.2.33 OsTaskResourceLock
Link time --
Post-build time --
Scope / Dependency scope: ECU
dependency: Required for scalability class 2 and 4
No Included Containers
10.2.34 OsTaskTimingProtection
(in seconds).
Multiplicity 0..1
Type EcucFloatParamDef
Range [0 .. INF]
Default value --
Post-Build Variant
false
Multiplicity
Post-Build Variant Value false
Multiplicity ConfigurationPre-compile time X All Variants
Class Link time --
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: ECU
dependency: Required for scalability class 2 and 4
Post-build time --
Scope / Dependency scope: ECU
dependency: Only available in scalability class 2 and 4
Included Containers
Container Name Multiplicity Scope / Dependency
This container contains the worst case time between getting
OsTaskResourceLock 0..*
and releasing a given resource (in seconds).
10.2.35 OsTimeConstant
No Included Containers
10.3.1 OsIoc
Included Containers
233 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
Example:
<NameSpace>_UniqueID
10.3.2 OsIocCommunication
The name shall begin with the name of the sending software service and
be followed by a unique identifier delivered by the sending software
service. In the case of RTE as user attention shall be paid on the fact that
Description
uniqueness for identifier names has to be reached over ports, data
elements, object instances and maybe additional identification properties
(E.g. Case 1:N mapping to 1:1).
Example:
<NameSpace>_UniqueID
Configuration Parameters
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
Included Containers
Container Name Multiplicity Scope / Dependency
Data properties of the data to be transferred on the IOC
OsIocDataProperties 1..*
communication channel.
Representation of receiver properties for one communication.
For each OsIocCommunication one (1:1) or many receivers
OsIocReceiverProperties 1..*
(N:M) have to be defined. This container should be instantiated
within an OsIocCommunication.
Representation of sender properties for one communication.
For each OsIocCommunication one (1:1) or many senders
(N:1 or N:M) have to be defined. Multiplicity > 1 (N:1 or N:M
OsIocSenderProperties 1..* communication) is only allowed for Multiplicity of
OsIocDataTypeRef = 1.
This container should be instantiated within an
OsIocCommunication.
10.3.3 OsIocSenderProperties
No Included Containers
10.3.4 OsIocReceiverProperties
minLength --
regularExpression --
Post-Build Variant
false
Multiplicity
Post-Build Variant Value false
Multiplicity ConfigurationPre-compile time X All Variants
Class Link time --
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
No Included Containers
10.3.5 OsIocDataProperties
Default value --
Post-Build Variant
false
Multiplicity
Post-Build Variant Value false
Multiplicity ConfigurationPre-compile time X All Variants
Class Link time --
Post-build time --
Value Configuration Class Pre-compile time X All Variants
Link time --
Post-build time --
Scope / Dependency scope: local
No Included Containers
239 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
11 Generation of the OS
reads generates/configures
«source»
operating
configuration generator
system
file
generates
linker
file
controls
«binary» «executable»
object linker executable
file program
1 1
1..* 1..*
(input-) (output-)
section UML 1.4 section
[SWS_Os_00172] ⌈The generator shall provide the user the ability of reading the
information of a selectable configuration file. ⌋ ( )
[SWS_Os_00173] ⌈The generator shall provide the user the ability of performing a
consistency check of the current configuration. ⌋ ( )
[SWS_Os_00179] ⌈If the consistency check of the read-in configuration file has not
run free of errors, the generator shall not generate/configure the operating system. ⌋
()
[SWS_Os_00370] ⌈The generator shall print out information about timers used
internally by the OS during generation (e.g. on console, list file). ⌋ (SRS_Frt_00022)
[SWS_Os_00815]⌈ The OS code shall wrap each declaration of Task, ISR and hook
functions with the Memory Mapping Allocation Keywords macros.
1 #define OS_START_SEC_<sadm>
2 #include "Os_MemMap.h"
3
4 <Task, ISR or hook functions declaration>
5
6 #define OS_STOP_SEC_<sadm>
7 #include "Os_MemMap.h"
where <sadm> is the shortName of the SwAddrMethod if configured in
OsMemoryMappingCodeLocationRef.⌋ (SRS_BSW_00351)
12 Application Notes
12.1 Hooks
In OSEK OS, PreTask & PostTask Hooks run at the level of the OS with unrestricted
access rights and therefore must be trusted. It is strongly recommended that these
hook routines are only used during debugging and are not used in a final product.
When an OS-Application is killed the shutdown and startup hooks of the OS-
Application are not called. Cleanup of OS-Application specific data can be done in
the restart task.
All application-specific hook functions (startup, shutdown and error) must return
(blocking or endless loops are not acceptable).
The following code fragment shows an example how a trusted function is called and
how the checks should be done.
StatusType system_service(
type1 parameter1,
type2 parameter2)
{
/* store parameters in a structure (parameter1 and parameter2) */
struct parameter_struct local_struct;
local_struct.name1 = parameter1;
local_struct.name2 = parameter2;
StatusType CallTrustedFunction(
TrustedFunctionIndexType ix,
TrustedFunctionParameterRefType ref)
{
/* check for legal service index and return error if necessary */
if(ix > MAX_SYSTEM_SERVICE)
return(E_OS_SERVICEID);
return(E_OK);
}
if (GetTaskID(&task) != E_OK)
task = INVALID_TASK;
can not be trusted OS-Applications because this would violate this protection feature.
The configuration process must ensure that this is the case.
“When allocating runnables to tasks, only allocate runnables from the same
software component into the same task.”
If multiple software components from the same application are to reside on the same
processor, then, assuming protection is required between applications (or parts
thereof) on the same processor, this rule could be modified to relax the scope of
protection to the application:
“When allocating runnables to tasks, only allocate runnables from the same
application into the same task.”
If an OS-Application is killed and the restart task is activated it can not assume that
the startup of the OS-Application has finished. Maybe the fault happened in the
application startup hook and no task of the application was started so far.
1. Using the FlexRay interface’s services for controlling timer interrupts related to
global time to provide a “hardware” counter tick source to drive the processing
of a schedule table (implicit synchronization)
247 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
2. Using the FlexRay interface’s service for accessing the current global time and
passing this into the OS through the SyncScheduleTable() OS service call
This section looks at the second option only.
Telling the ScheduleTable that GlobalTime can be done when the application detects
that the FlexRay controller has lost synchronization with the network (by polling the
controller sync status). The following code indicates how this can be used to force an
associated ScheduleTable into the SCHEDULETABLE_RUNNING state from the
SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS state.
Fr_SyncStateType CurrentSyncStatus;
if (FrIf_GetSyncState(Controller, &CurrentSyncStatus) == E_OK) {
if (CurrentSyncStatus == FR_ASYNC ) {
SetScheduleTableAsync(Table);
}
}
Of course, other actions are possible here, like stopping the ScheduleTable, as best
fits user requirements.
Since OIL and XML are both ASCII formats a tool vendor may offer a possibility to
import (old) OIL files and to store them as (AUTOSAR OS) XML files. Currently all
known vendors support at least the import of existing OIL configurations.
Note that for showing conformance to the OSEK OS specification, each OSEK OS
vendor must support OIL. This means that practically each AUTOSAR OS vendor will
offer some sort of import of OIL configurations – at least to show the OSEK OS
conformance.
General information about how to retrieve the current (active) Task or ISR and
their (current) priority and (current) stack.
For ISRs: Information about the name of interrupts, their mapping to the ISR
identifier, the associated hardware and the used stack(s).
For Tasks: Information about the name of the Task, its identifier, the task
state, the possible priorities, the event mask (if its an extended task), the OS-
Application to whom the Task belongs (if existant) and the used stack.
For Resources: Information about the name of the Resource, its mapping to
the identifier, its priority and the current owner (the Task/ISR which currently
holds the Resource)
7
This work can be done automatically by a configuration tool duirng importing an OIL file
249 of 255 Document ID 034: AUTOSAR_SWS_OS
- AUTOSAR confidential -
Specification of Operating System
AUTOSAR CP Release 4.3.1
For Alarms: Information about the name of the Alarm, its mapping to the
identifier, the counter to whom it belong, the action which is executed on
expiry and the current state (running or stopped). In running state the next
expiry in ticks and the possible cycle time shall be also published.
For Counters: Information about the name of the Counter, its mapping to the
identifier, its associated alarms and the current counter value.
For Schdule Tables: Information about the name of the Schedule Table, its
mapping to the identifier, its current state and the next expiry point (if the table
is running).
For OS-Applications: Information about the name of the OS-Application, its
mapping to the identifier, its current state and the memory sections assigned
to it (if memory protection is used).
When using the memory protection unit, it is reasonable if two or more protected
region descriptors are available for peripheral protection mechanism. The region
descriptors shall be programmed to allow access to those peripherals the current
OS-Application shall work with. The defined regions shall cover all memory mapped
configuration registers for the periphiherals to be protected. The advantage of using
the MPU is that the configuration is the same as for memory protection. One of the
disadvantages of this method is that it could be impossilbe to cover all peripheral
control registers with available MPU region descriptors. The number of such
descriptors is typically low.
Beware that using this method may have implication to the linker file of the project
software configuration.
Second method is using a dedicated register protection schema. This method shall
allow to precisely select peripherals for every OS Application. However the number of
peripherals may make the register protection implementation rather bulky. Therefore
it is advisable to reduce the number of protected peripherals to a reasonable value.
For both methods the configuration shall be placed into custom OS Application
properties. The configuration shall be active when a task (or ISR) of a particular OS
Application is running.
Integration code shall stop all signals and signalgroups during its OsApplication
restart. This ensures that no late asynchronous notification will occur after the
OsApplication restart. These signals and signalgroups can be then safely restarted if
needed.
A SW-C shall cancel jobs on all its memory blocks with a call to NvM_CancelJobs
during the restart of its OsApplication. As the job might have already been started,
the call to NvM_CancelJobs can return an error; in that case, the OsApplication shall
wait until end of the job to continue. After all jobs are ensured to be cancelled, then
all memory blocks shall be reset to their initial value, in order to avoid inconsistency
of data which might have been written before the cancellation.
Any SW-C having responsible for requesting mode or state to BSW mode managers
shall always request a default mode upon a restart of its OsApplication. Thus the
BSW mode manager would not be stuck into a mode previously requested by the
OsApplication before its termination. To support this task, note that RTE offers
mechanisms to handle partition stop and restart wrt. mode machines. For mode
managers an "error mode" to be set by RTE can be identified. For mode user
partition the behaviour can also be selected. Furthermore an interaction to BswM to
trigger an action list in case of partition restart can be initiated. Refer to RTE
specification for details.
13.1.1 Package
13.2 Overview
The AUTOSAR Operating System is normally not used directly by SWCs. Even the
other BSW modules which are below the RTE are using the BSW Scheduler to have
access to OS services. The BSW Scheduler of course uses the OS to implement its
features, e.g. critical sections.
Nevertheless there is one case where it makes sense to allow SWCs access to
services of the OS:
Timer services
Since the number of timers in an ECU is limited it make sense to share these
units across several SWCs. The functionality of the timer services of the OS
which are offered to the SWCs are:
A service to get the current value of a – hardware or software – counter
A service which calculates the time difference between the current timer value
and a given (previouls read) timer value
Both services will return real time values instead of ticks. This limits the access
to the services to those counters which are counting time. Other counters e.g.
counting errors or angles are not accessible.
The notation of possible error codes resulting from server calls follows the approach
in the meta-model. It is a matter of the RTE specification [9], how those error codes
will be passed via the actual API.
2. The generator can uniquely identify the address spaces of the data output
sections with symbols using the naming convention (see »memory allocation
keywords« _STOP_SEC_VAR and _START_SEC_VAR for start and stop
symbols) in the specification mentioned above.
The input data sections in the object files of an OS-Application can then be assigned
to the output sections (with potential tool support). Usually, this is one segment for
global data, and one segment for code.
To archieve portability, the user shall group all variables belonging to a private data
section (Task/ISR or OS-Application) in separate files.