Documente Academic
Documente Profesional
Documente Cultură
Rev. 1.2
R E Q U I R E D
HC12
OSEK
A G R E E M E N T
Operating System
User’s Manual
Rev. 1.2
N O N - D I S C L O S U R E
May 19, 1999
User’s Manual
R E Q U I R E D
A G R E E M E N T
death may occur. Should Buyer purchase or use Motorola products for
any such unintended or unauthorized application, Buyer shall indemnify
and hold Motorola and its officers, employees, subsidiaries, affiliates,
and distributors harmless against all claims, costs, damages, and
expenses, and reasonable attorney fees arising out of, directly or
indirectly, any claim of personal injury or death associated with such
unintended or unauthorized use, even if such claim alleges that Motorola
was negligent regarding the design or manufacture of the part. Motorola
and are registered trademarks of Motorola, Inc. Motorola, Inc. is an
Equal Employment Opportunity/Affirmative Action Employer.
2 MOTOROLA
R E Q U I R E D
Legal Notices
iii
The information in this document has been carefully checked and is
believed to be entirely reliable, however, no responsibility is assumed for
inaccuracies. Furthermore, Motorola reserves the right to make changes
to any products herein to improve reliability, function or design. Motorola
does not assume liability arising out of the application or use of any
product or circuit described herein; neither does it convey any license
under its patent rights or the rights of others.
A G R E E M E N T
The software described in this document is furnished under a license
agreement. The software may be used or copied only in accordance with
the terms of the agreement.
N O N - D I S C L O S U R E
Motorola.
While every effort has been made to ensure the accuracy of all
information in this document, Motorola assumes no liability to any party
for any loss or damage caused by errors or omissions or by statements
of any kind in this document, its updates, supplements, or special
editions, whether such errors are omissions or statements resulting from
negligence, accident, or any other cause. Motorola further assumes no
liability arising out of the application or use of any product or system
described herein; nor any liability for incidental or consequential
damages arising from the use of this document. Motorola disclaims all
warranties regarding the information contained herein, whether
expressed, implied or statutory, including implied warranties of
merchantability or fitness for a particular purpose.
TRADEMARKS
Table of Contents
Section 1. Overview
Section 2. Notation
A G R E E M E N T
2.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2 Manual Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3 Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4 Definitions, Acronyms and Abbreviations . . . . . . . . . . . . . . . . . 27
2.5 Installation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.5.1 Required Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.5.2 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.6 Technical Support Information . . . . . . . . . . . . . . . . . . . . . . . . . 29
N O N - D I S C L O S U R E
3.2 Processing Levels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3 Conformance Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.4 OSEK OS Overall Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5 Application Program Interface . . . . . . . . . . . . . . . . . . . . . . . . . 37
Section 5. Scheduler
N O N - D I S C L O S U R E
5.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.2.1 Simple Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.3 Scheduling Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.3.1 Non-preemptive Scheduling . . . . . . . . . . . . . . . . . . . . . . . . 67
5.3.2 Full-preemptive Scheduling. . . . . . . . . . . . . . . . . . . . . . . . . 68
5.3.3 Mixed-preemptive Scheduling . . . . . . . . . . . . . . . . . . . . . . . 69
5.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.4.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.4.2 Run-time Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.4.3 Scheduler Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
R E Q U I R E D
6.3 ISR Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.4 ISR Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.4.1 ISR Category 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.4.2 ISR Category 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.4.3 ISR Category 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.5 Interrupt Flag Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.6 Local Variables Considerations . . . . . . . . . . . . . . . . . . . . . . . . 78
6.7 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.7.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
A G R E E M E N T
6.7.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.7.3 Run-time Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.7.4 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.7.5 ISR Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.7.6 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
N O N - D I S C L O S U R E
7.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.4.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.4.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.4.3 Run-time Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.4.4 Resource Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Section 9. Events
9.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
9.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
9.3 Events and Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
9.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
A G R E E M E N T
R E Q U I R E D
11.4.3 Possible Error Reasons. . . . . . . . . . . . . . . . . . . . . . . . . . .128
11.5 Start-up Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
11.6 Application Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
11.7 System Shutdown. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
11.8 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
11.8.1 Configuration Options . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
A G R E E M E N T
12.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
12.3 Application Configuration File . . . . . . . . . . . . . . . . . . . . . . . . .134
12.4 OIL Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
12.4.1 OIL File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
12.4.2 Standard OIL Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
12.4.3 Extended OIL Format . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
12.4.4 Implementation Definition . . . . . . . . . . . . . . . . . . . . . . . . .135
12.4.4.1 Implementation Definition Grammar . . . . . . . . . . . . . . .136
12.4.5 Application Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
12.4.5.1 Object Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
12.4.5.2 Include Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
12.4.5.3 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
N O N - D I S C L O S U R E
12.4.5.4 File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
12.4.6 Configuration File Rules . . . . . . . . . . . . . . . . . . . . . . . . . .140
R E Q U I R E D
15.2.2 Cosmic Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180
15.3 Interrupt Flag Manipulation Specific Features . . . . . . . . . . . .180
15.4 HC12 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182
15.4.1 Base Page Memory Usage . . . . . . . . . . . . . . . . . . . . . . . .182
15.4.1.1 Mapping RAM and REGISTERS . . . . . . . . . . . . . . . . . .182
15.4.2 Interrupt Vector Table . . . . . . . . . . . . . . . . . . . . . . . . . . . .183
15.4.3 The Banked Memory Model Support. . . . . . . . . . . . . . . . .184
15.4.3.1 Banked Memory Model Overview . . . . . . . . . . . . . . . . .184
15.4.3.2 Configuration of the Application for Banked Memory. . .185
15.4.3.3 Cosmic Compiler Issue . . . . . . . . . . . . . . . . . . . . . . . . .186
A G R E E M E N T
15.4.4 Recommendations on System Properties . . . . . . . . . . . . .187
15.4.4.1 UseMainStack property . . . . . . . . . . . . . . . . . . . . . . . . .187
15.4.4.2 UseSameContext Property . . . . . . . . . . . . . . . . . . . . . .187
15.4.4.3 InterruptMaskControl Property . . . . . . . . . . . . . . . . . . . .187
15.4.4.4 CounterSize Property. . . . . . . . . . . . . . . . . . . . . . . . . . .188
15.4.4.5 Unused Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188
15.4.5 System Timer Hardware . . . . . . . . . . . . . . . . . . . . . . . . . .188
15.4.6 Scheduler Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . .191
15.4.7 Alarms Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . .191
15.5 Task Stack Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192
N O N - D I S C L O S U R E
16.2 System Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
16.3 Using OS Extended Status for Debugging . . . . . . . . . . . . . . .193
16.4 Context Switch Routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . .194
16.5 Stack Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195
16.6 Known Problems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195
R E Q U I R E D
17.6.10 SetAbsAlarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235
17.6.11 CancelAlarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
17.6.12 GetAlarmBase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
17.6.13 GetAlarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238
17.6.14 Examples for Counter and Alarm Management . . . . . . . .239
17.7 Event Management Services . . . . . . . . . . . . . . . . . . . . . . . . .242
17.7.1 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
17.7.2 Event Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
17.7.3 SetEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243
17.7.4 ClearEvent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244
A G R E E M E N T
17.7.5 GetEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
17.7.6 WaitEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
17.7.7 Examples of Using Events . . . . . . . . . . . . . . . . . . . . . . . .247
17.8 Communication Management Services . . . . . . . . . . . . . . . . .249
17.8.1 Data Types and Identifiers . . . . . . . . . . . . . . . . . . . . . . . .249
17.8.2 SendMessage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .250
17.8.3 ReceiveMessage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252
17.8.4 GetMessageResource. . . . . . . . . . . . . . . . . . . . . . . . . . . .253
17.8.5 ReleaseMessageResource . . . . . . . . . . . . . . . . . . . . . . . .254
17.8.6 GetMessageStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255
17.8.7 Examples of Using Messages . . . . . . . . . . . . . . . . . . . . . .256
17.9 Operating System Execution Control . . . . . . . . . . . . . . . . . . .259
N O N - D I S C L O S U R E
17.9.1 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259
17.9.2 GetActiveApplicationMode . . . . . . . . . . . . . . . . . . . . . . . .259
17.9.3 StartOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260
17.9.4 ShutdownOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260
17.9.5 Examples of Application Modes Usage. . . . . . . . . . . . . . .261
17.9.6 Hook Routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264
17.9.6.1 ErrorHook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264
17.9.6.2 PreTaskHook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
17.9.6.3 PostTaskHook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
17.9.6.4 IdleLoopHook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
17.9.6.5 StartupHook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
17.9.6.6 ShutdownHook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268
R E Q U I R E D
E.3.2 TASK Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345
E.3.3 ISR Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E.3.4 STACK Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E.3.5 RESOURCE Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348
E.3.6 ALARM Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348
E.3.7 COUNTER Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349
E.3.8 MESSAGE Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349
E.3.9 EVENT Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351
A G R E E M E N T
N O N - D I S C L O S U R E
List of Figures
Figure Title Page
A G R E E M E N T
4-2 Task status model with task transitions for Basic Tasks . . . 44
4-3 Task management architecture . . . . . . . . . . . . . . . . . . . . . . 46
4-4 Task priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4-5 Persistent task node assignment . . . . . . . . . . . . . . . . . . . . . 53
4-6 Task link table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4-7 Fixed stack linked with the task node. . . . . . . . . . . . . . . . . . 56
4-8 Dynamic stack allocation from the stack pool . . . . . . . . . . . 57
4-9 Persistent stack allocation from the stack pool . . . . . . . . . . 58
4-10 Static stack allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5-1 Non-preemptive scheduling . . . . . . . . . . . . . . . . . . . . . . . . . 68
5-2 Full-preemptive scheduling . . . . . . . . . . . . . . . . . . . . . . . . . 69
7-1 Priority Ceiling Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
N O N - D I S C L O S U R E
8-1 Counters and alarms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8-2 Two cases for the absolute alarm . . . . . . . . . . . . . . . . . . . . 98
9-1 Synchronization by events in case of full-preemptive
scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107
9-2 Synchronization by events in case of full-preemptive
scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
10-1 Operations with Queued Messages . . . . . . . . . . . . . . . . . .116
11-1 System startup in the OSEK OS . . . . . . . . . . . . . . . . . . . .129
14-1 Application building process. . . . . . . . . . . . . . . . . . . . . . . .173
15-1 Banked Memory Model . . . . . . . . . . . . . . . . . . . . . . . . . . .185
18-1 Application Building Process with ORTI Support . . . . . . . .270
List of Tables
Figure Title Page
A G R E E M E N T
4-2 States and status transitions in the case of Basic Tasks . . . . 43
4-3 Task Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4-4 Task Management Run-time Services . . . . . . . . . . . . . . . . . . 62
6-1 Interrupt Management Services in the OSEK OS . . . . . . . . . 81
8-1 Counter and Alarm Management Run-time Services . . . . . .102
9-1 Event Management Run-time Services . . . . . . . . . . . . . . . .109
10-1 Features of the Message Concept . . . . . . . . . . . . . . . . . . . .113
10-2 Task Management Run-time Services . . . . . . . . . . . . . . . . .119
11-1 OSEK OS system services for hook routines . . . . . . . . . . . .124
11-2 OSEK OS Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
14-1 System Generator command line options . . . . . . . . . . . . . .174
15-1 Parameters to define System Timer hardware . . . . . . . . . . .189
18-1 ORTI Generator Command Line Options . . . . . . . . . . . . . . .276
N O N - D I S C L O S U R E
B-1 OSEKOS_20 version of the Operating System run-time services
timing characteristics (HC12D60, Cosmic software) . . . . . .285
C-1 OSEKOS_20 version of the Operating System memory
requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .292
E-1 OSEK OS services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319
E-2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .322
E-3 Constructional elements . . . . . . . . . . . . . . . . . . . . . . . . . . . .323
E-4 OSEK Operating System run-time services return values
and error values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .324
E-5 OSEK Operating System constants . . . . . . . . . . . . . . . . . . .325
E-6 OS Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326
E-7 TASK Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345
E-8 ISR Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E-9 STACK Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
E-10 RESOURCE Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . .348
Section 1. Overview
A G R E E M E N T
OSEK OS conforms to the following requirements:
N O N - D I S C L O S U R E
A wide range of scalability, a set of system services, various scheduling
mechanisms, and convenient configuration features make the OSEK
Operating System feasible for a broad spectrum of applications and
hardware platforms.
1. The term OSEK means ‘Offene Systeme und deren Schnittstellen fur die Elektronik im Kraft-
fahrzeug’ (Open systems and the corresponding interfaces for automotive electronics). A real-
time operating system, software interfaces and functions for communication and network man-
agement tasks are thus jointly specified within the OSEK standard.
MOTOROLA Overview 21
Overview
R E Q U I R E D
Task Management
Scheduling Policies
Event Control
A G R E E M E N T
Interrupt Management
Resource Management
Communication1
1. Communication part of OSEK Operating System conforms the specification of the OSEK Com-
munication System, version 2.1, revision 1, 17 June 1998.
2. Counter Management part of OSEK Operating System conforms the specification of the OSEK
Operating System Application Program Interface version 1.00, 11 September 1995.
22 Overview MOTOROLA
Overview
R E Q U I R E D
Error treatment
ORTI Subsystem
A G R E E M E N T
and capability of the OS. These Conformance Classes do not only differ
concerning the number of services they provide, but also with regard to
their capabilities and scalability. The classes are based on one another
in upwardly compatible fashion. The Conformance Classes are
generated by meaningful grouping of services (see
Section 3.3 Conformance Classes).
N O N - D I S C L O S U R E
files. Thus, the user can adapt the Operating System to the control task
and the target hardware. OS cannot be modified later at execution time.
MOTOROLA Overview 23
Overview
R E Q U I R E D
A G R E E M E N T
N O N - D I S C L O S U R E
24 Overview MOTOROLA
R E Q U I R E D
User’s Manual — OSEK Operating System
Section 2. Notation
2.1 Contents
2.2 Manual Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
A G R E E M E N T
2.3 Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4 Definitions, Acronyms and Abbreviations . . . . . . . . . . . . . . . . . 27
2.5 Installation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.6 Technical Support Information . . . . . . . . . . . . . . . . . . . . . . . . . 29
N O N - D I S C L O S U R E
Section 2 Notation contains a description of the Manual structure,
typographical conventions and the list of acronyms.
MOTOROLA Notation 25
Notation
R E Q U I R E D
26 Notation MOTOROLA
Notation
Typographical Conventions
R E Q U I R E D
Appendix D System Generation Error Messages explains OSEK OS
System Generator error messages.
A G R E E M E N T
boldface type
Bold is used for important terms, notes and warnings.
Italics
Italics are used for all OSEK names of directives, macros,
constants, routines and variables.
Courier font
Courier typeface is used for code examples in the text.
Courier Italic
Courier Italic typeface is used for OSEK terms when these are
first introduced.
N O N - D I S C L O S U R E
2.4 Definitions, Acronyms and Abbreviations
MOTOROLA Notation 27
Notation
R E Q U I R E D
MO Message object
All supplied makefiles are developed for the Microsoft C++ NMAKE
utility.
28 Notation MOTOROLA
Notation
Technical Support Information
R E Q U I R E D
2.5.2 Installation
1. Insert the installation disk into a 3.5” floppy drive. The following
instructions assume that the drive letter is a:. If another drive is
chosen, substitute that drive letter where appropriate.
2. Run the A:\SETUP.EXE program either from the File Manager or
Program Manager.
3. Follow the prompts and instructions of the installation program.
4. After installation verify the consistency of the package by means
A G R E E M E N T
of comparing the real set of files and directories with the list in
FILELIST.TXT file.
After installation, the hard drive should contain the root directory of
OSEK which contains a set of files in the following subdirectories:
N O N - D I S C L O S U R E
• MAN User’s Documentation
Email: osek@helpline.sps.mot.com
Phone: +44 13 55 35 53 98 (English)
+49 89 92 10 38 83 (German or English)
MOTOROLA Notation 29
Notation
R E Q U I R E D
30 Notation MOTOROLA
R E Q U I R E D
User’s Manual — OSEK Operating System
3.1 Contents
3.2 Processing Levels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
A G R E E M E N T
3.3 Conformance Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.4 OSEK OS Overall Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5 Application Program Interface . . . . . . . . . . . . . . . . . . . . . . . . . 37
N O N - D I S C L O S U R E
The OSEK Operating System provides a defined set of interfaces for the
user. These interfaces are used by entities which are competing for the
CPU. There are two types of entities:
made between the management of tasks with and without waiting state
(Extended and Basic Tasks, see Section 4.2 Task Concept). The run
time context refers to resources which are occupied at the beginning of
execution time and are released again once the task is finished.
priorities;
• The task’s priority is statically assigned by the user.
R E Q U I R E D
The definition of the functionalities provided by each Conformance Class
depends on the properties of the tasks and on the scheduling behavior.
As the task properties (Basic or Extended, see Section 4.3 Task State
Model) have a distinct influence on CC, they also assume part of their
names. There are Basic-CC and Extended-CC, and each of these
groups can have various “derivatives”.
A G R E E M E N T
• Task types (see Section 4.3 Task State Model);
• Number of tasks per priority.
BT only BT and ET
1 task/priority
no multiply activations BCC1 ECC1
N O N - D I S C L O S U R E
Figure 3-1. Restricted upward compatibility for conformance
classes
• BCC1 – only Basic tasks, limited to one request per task and one
task per priority, while all tasks have different priorities;
• BCC2 – like BCC1, more than one task per priority possible and
multiple activation admissible;
• ECC1 – like BCC1, plus Extended tasks;
• ECC2 – like BCC2, plus Extended tasks without multiply activation
admissible.
BCC1 defines the minimum Conformance Class of the OSEK OS, ECC2
defines its maximum CC.
order.
R E Q U I R E D
Table 3-2 presents maximal values for system resources:
Table 3-2. OSEK OS maximal system resources
BCC1 BCC2 ECC1 ECC2
Number of tasks which are
limited only to RAM and/or ROM available(1)
not in the suspended state
Number of tasks per priority limited only to RAM available
BT: -
Number of events per task -
ET: 8(2)
Number of priority classes 256(2)
only
A G R E E M E N T
Resources limited only to RAM and/or ROM available(3)
Scheduler
Alarm limited only to RAM and/or ROM available
Messages limited only to RAM and/or ROM available
2. Keeping this value allows a byte to be used which improves RAM and ROM requirements
and execution speed.
N O N - D I S C L O S U R E
3.4 OSEK OS Overall Architecture
The OSEK OS is a real-time operating system, which is executed within
a single electronic control unit. It provides local services for user’s tasks.
The OSEK OS consists of the following components:
R E Q U I R E D
Section 12 System Configuration and Section 14 Building of
Application for details about system generation.
A G R E E M E N T
OSEK OS data types are described in subsections dedicated to the
corresponding mechanisms. Syntax of system calls and system
configuration statements are described briefly in corresponding
subsections and in detail in Section 12 System Configuration and
Section 17 System Services.
NOTE: The user’s source code shall strictly correspond to the rules presented
in this Manual.
The OSEK OS can has the Extended Status. It means that additional
checking is made inside all OS activities and extended return codes are
returned by all OS services to indicate errors if they have occurred. See
N O N - D I S C L O S U R E
Section 17 System Services and Section 11.4 Error Handling
about Extended Status return values. To provide the Extended Status in
the system, the configuration option STATUS must be set to
EXTENDED at the configuration stage.
4.1 Contents
4.2 Task Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
A G R E E M E N T
4.3 Task State Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.4 Task Activation and Termination . . . . . . . . . . . . . . . . . . . . . . . 44
4.5 Task Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.6 Task Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.7 Task Related Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.8 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
N O N - D I S C L O S U R E
executed according to their real-time requirements. These parts can be
implemented by means of tasks. A task provides the framework for the
execution of functions. The Operating System provides parallel and
asynchronous task execution organization by the scheduler.
OSEK OS provides a set of tools for the user to manage tasks. They are
activated before their execution – memory resources needed for a task
are allocated. Tasks may be terminated after necessary actions are
performed – memory resources are released. After a task is activated, it
may run and terminate or it may be implemented in an endless loop with
at least one synchronizing system call. It is not possible to run several
parallel endless loops without switching mechanism (scheduler). Tasks
can be switched during their execution from one to another, or may be
interrupted by ISR. If no task is active, only the scheduler idle loop runs
(see Section 5.2 General). Task states and transitions between them
are discussed in Section 4.3 Task State Model.
for activated tasks. Also, each task has its own stack assigned. See
Section 4.7 Task Related Resources about the task control block, the
task configuration table and the task stack.
Every running task is represented by its run time context. This refers to
CPU registers and some compiler-dependent ‘pseudoregisters’ in RAM.
When the task is interrupted or preempted by another task, the run time
context is saved in the task’s stack. Run time context differs for non-
preemptive and preemptive tasks; for preemptive tasks, more RAM is
required to save the context. Therefore, for a mixed-preemptive system
(it means that both non-preemptive and preemptive tasks can exist in the
system, see Section 5.3 Scheduling Policy) a distinction can be made
by the Operating System between these types of contexts. It is
controlled by the UseSameContext configuration option. In the case
where different contexts are saved for non-preemptive and preemptive
tasks, the OS must perform additional code to distinguish the task type.
R E Q U I R E D
Otherwise, some more RAM is required to store the ‘full’ context for non-
preemptive tasks too. The use of this option is application dependent.
A G R E E M E N T
4.3.1 Extended Tasks
N O N - D I S C L O S U R E
for allocation of the processor. The scheduler
decides which ready task is executed next.
• waiting A task cannot be executed (any longer),
because it has to wait for at least one event
(see Section 9 Events).
• suspended In the suspended state, the task is passive and
does not occupy any resources, merely ROM.
running
wait terminate
release activate
ready
Figure 4-1. Task status model of an Extended Task with its task
transitions
Table 4-1. States and status transitions in the case of Extended Tasks
Transition Former state New state Description
N O N - D I S C L O S U R E
release waiting ready Events have occurred on which a task has waited.
R E Q U I R E D
There is no provision for a direct transition from the suspended state into
the waiting state. This transition is redundant and would add to the
complexity of the scheduler. The waiting state is not directly entered
from the suspended state since the task starts and explicitly enters the
waiting state on its own.
The state model of Basic Tasks is nearly identical to the Extended Tasks
state model. The only exception is that Basic Tasks do not have a
A G R E E M E N T
waiting state.
N O N - D I S C L O S U R E
does not occupy any resources, merely ROM.
Table 4-2. States and status transitions in the case of Basic Tasks
Transition Former state New state Description
running
terminate
activate
ready
Figure 4-2. Task status model with task transitions for Basic Tasks
• For of a task suited for multiple activation, all task activations are
noted down. It means that whenever a task is activated by the
application, the appropriate task is started at the next possible
time, even if it is already running while the request is issued. In
such cases, the request is saved by the operating system, so the
task can be started again by the operating system once it has
been terminated. This procedure is repeated several times until all
requests have been completed. In the OSEK OS the activation of
the basic task is queued in Scheduler queues to preserve task
activation order.
R E Q U I R E D
• In the case of a task suited for single activation, either the task
activation is noted down, or, if the task has already been
requested, nothing happens.
A G R E E M E N T
During task activation the ActivateTask service analyzes the task
configuration table of the task to be activated, and allocates a stack
buffer and a task node as specified in the task configuration table. In the
figure the typical allocation method is shown – a stack buffer is retrieved
from the stack pool and a task node from the scheduler’s list of free task
nodes. If these resources are available, then the task node is initialized
and inserted into the scheduler’s queues to be dispatched.
If the task does not have multiply activation requests, then the
TerminateTask and ChainTask services release both the task node and
the stack buffer and return them to the system for re-use. If a task has
multiple activation requests, then TerminateTask and ChainTask
N O N - D I S C L O S U R E
services do not release the task node and the stack buffer because
these structures will be used for task reactivation.
Task
Free task configuration
table
node
Stack
A G R E E M E N T
buffer
Initialized Running
task mode task mode
Scheduler queues
But, in the case where requested resources aren’t available, it may lead
to indeterministic behavior of the operating system. This situation may
occur when too many tasks are activated. To avoid that weakness, the
user is also allowed to statically assign task control blocks and stack
areas for critical tasks. Such explicitly defined resources are held by a
task for the application life time. In this case, the task control block and/or
the task stack are not released and cannot be re-assigned for other
tasks.
R E Q U I R E D
4.5 Task Properties
In OSEK OS every task is characterized by the set of properties. These
properties define the task behavior and resource allocation method.
Each task property has its own name, and the user defines the task
features by setting the corresponding properties in the task definition.
See Section 12 System Configuration about task definition. The list of
possible task properties is provided in Table 4-3.
A G R E E M E N T
Table 4-3. Task Properties
Property Name Property Value Description
BASIC Basic task
TYPE
EXTENDED Extended task
NON Non-preemptive task
SCHEDULE
FULL Preemptive task
AUTOSTART TRUE/FALSE Activate the task at system start-up
A persistent task control block is assigned (linked with the task
PersistentNode TRUE/FALSE
configuration tables)
A stack should be allocated to the task during task activation –
POOLSTACK
dynamic stack allocation from the stack pool
A stack is explicitly assigned to the task (address of the top of
StackMethod OWNSTACK
N O N - D I S C L O S U R E
the stack is included in the task configuration table)
A task node stack is implicitly assigned to be used by the task
NODESTACK
(during the task activation)
A persistent stack from the stack pool (the pool identifier is
PersistentStack TRUE/FALSE
included in the task configuration table)
On the basis of the task priority the scheduler decides which is the next
of the ready tasks to be transferred into the running state. Tasks are
started depending on their order of activation, according to the FIFO
mechanism, whereby an Extended Task in the waiting state does not
block the start of subsequent tasks of identical priority.
A G R E E M E N T
Figure 4-4 illustrates how tasks priorities affect the order of their
execution
.
N 3 2 1 0
FIFO
list of
ready
tasks •••
N O N - D I S C L O S U R E
high low
priority
actually processed
CPU and terminated task scheduler next running task
(with priority N)
processor time
R E Q U I R E D
Several tasks of different priorities are in the ready state – three tasks of
priority 3, one of priority 2, one of priority 1, and two priority 0 tasks. The
task that has waited the longest time, depending of its order of
requesting, is shown at the bottom of each FIFO queue. The CPU has
just processed and terminated a task with priority N. The scheduler
selects the next task to be processed (priority 3, first FIFO location).
Before priority 2 tasks can be processed, all tasks of higher priority must
have been executed completely.
Thus, the following three steps are made to switch to the next running
task:
A G R E E M E N T
1. The scheduler searches for all tasks in the ready state.
2. From the set of ready tasks, the scheduler determines the set of
tasks with the highest priority.
3. Within the set of tasks in the ready state and of the highest priority,
the scheduler finds the task that has been in the ready state the
longest time (‘oldest’ task).
N O N - D I S C L O S U R E
not assigned statically). These resources uniquely define task properties
and the task run-time context. Also, at run-time the task link table exists
in RAM to provide the correspondence between the task control block
and the task configuration table.
1. OSEK OS uses internal task priority during run-time. This priority is calculated by OSEK OS
SysGen tool during application configuration. It may differ from user-defined task priority as a re-
sult of optimization.
R E Q U I R E D
Some of these parameters are specified by the user during system
configuration by means of the TASK object definition, while others are
generated automatically. See Section 12 System Configuration and
Section 14 Building of Application about system configuration and
building an application.
A G R E E M E N T
the task is not in the suspended state. Except persistent node
assignment (see Section 4.7.2.1 Persistent Node Assignment), this
task control block is linked to the scheduler’s list of free nodes when it is
not assigned to the task. In general, this block is allocated to the task
during task activation, and it is initialized at that moment (see Figure 4-
3).
• A pointer for linking the task control block into scheduler queues.
This field is absent if the simplified scheduler is used in the
system;
• The current task status. Some of the status bits are copied from
N O N - D I S C L O S U R E
the task property bits of the task configuration table. Other bits are:
– a task waiting bit, which is set when the task is waiting for an
event(s);
– a scheduler bit, which is set when the task occupies the
scheduler.
• The current task priority. In general, the current priority may differ
from the starting priority (located in the task configuration table)
during the periods of time when the task occupies the resources,
see Section 7.3.1 Priority Ceiling Protocol.This field is absent
if the simplified scheduler is used in the system;
• A pointer to the task configuration table;
• The task context (for non-preemptive tasks), or a pointer to the
stack frame, where the context is saved (for preemptive tasks).
Note, that for mixed-preemptive scheduling systems, both non-
• The real address of the top of the task stack. This field is absent if
multiple activation is not supported and the system configuration
option ChainTaskItself is turned off.
The task control block size depends on the system configuration and
task properties. See Appendix B System Service Timing
The task control block may be statically assigned to the task. This
mechanism prevents a task activation failure due to missing free task
nodes and increases the speed of task activation/termination operations
by means of excluding a task node queue manipulation. This
mechanism is called persistent task node assignment, and it is illustrated
in Figure 4-5. To define persistent node assignment for the task, the
task property PersistentNode must be set in the TASK definition for this
R E Q U I R E D
task and the system configuration option PersistentNode must be turned
on.
A G R E E M E N T
of the stack allocation options (see Section 4.7.4 Task Stack).
N O N - D I S C L O S U R E
the task node address Free task node #4
Activate task
The task link table contains one element per task configured in the
system. The element contains a NULL-pointer if the task is in the
suspended state, or the task node address if the task is in the non-
suspended state (it is saved there during task activation). For instance,
in Figure 4-6 task#1 is not activated, while task#2 and task#8 are
activated. Task#2 uses task node#4, and task#8 uses task node#1. The
task configuration table contains the address of the task link element.
The system uses this address when the task is referenced, and looks at
the contents of the element of the task link table to define the current
state of the task.
If the OSEK OS supports task multiple activations, then the task link
table contains one additional element per task. The element is the
R E Q U I R E D
counter of times of activation. That is, the content of this field increments
each time the task to be activated is in the non-suspended state, and
decrements each time the task is terminating.
During run-time, every task has its own stack. The stack is either
dynamically assigned to a task during its activation or statically allocated
A G R E E M E N T
for a task during system initialization. If a stack is allocated dynamically,
it is got from a stack pool. Several options are possible for static stack
assignment during system start-up.
N O N - D I S C L O S U R E
is unlinked from the pool and assigned to the task during task activation.
During task termination the stack buffer is returned to the stack pool.
The simplest method of stack allocation is to use task node stacks. Each
task in the OSEK Operating system has the stack linked with a task
node. The size of this stack is the same for all tasks. It is defined by
means of the corresponding OS property NodeStackSize. See
Section 4.7.5 Allocation of Fixed Stack Linked with the Task Node
for this option.
These options may be used simultaneously in the system, but each task
must use only one of them. These options allow the user to optimize
stack usage in the application.
stack pointer
task node stack
R E Q U I R E D
4.7.5.1 Dynamic Stack Allocation from the Stack Pool
stack buffer
Stack buffer
stack pool node stack pointer
A G R E E M E N T
Figure 4-8. Dynamic stack allocation from the stack pool
N O N - D I S C L O S U R E
space requirements for various tasks.
NOTE: The user is responsible for the proper quantity of stack buffers to avoid
a possible failure of task activation if there are no stack buffers left. Also,
the increased time of task activation/termination due to stack pool
manipulations timing should be taken into consideration. This method
allows most efficient RAM distribution for task stacks.
To use persistent stack allocation from the stack pool the user should set
both PersistentNode and PersistentStack task properties. The system
configuration option PersistentStack must be turned on. In this case, the
task stack is allocated from the stack pool during system initialization
and the address of the stack is written in the task control block, which is
Buffer
Buffer
Persistent Task node #3
Task nodes
buffer
stack buffer
Free task node #1 Buffer
stack pointer
Free task node #2
NOTE: Persistent stack from a stack pool may be assigned only for the task with
assigned persistent task node and with assigned stack pool.
R E Q U I R E D
4.7.5.3 Explicit Stack Allocation
stack pointer
top of stack
A G R E E M E N T
Persistent stack allocation is selected when the OWNSTACK value is
given to the StackMethod property in the task definition. The system
configuration option TaskOwnStack must be turned on. The user must
also specify the stack size. In the figure above, task #4 has a stack
permanently assigned to the task. The user is allowed to assign one
static stack area to different tasks, if these tasks are not activated
simultaneously. But with such stack allocation there is the overhead
connected with non-used RAM areas when the task is not activated.
N O N - D I S C L O S U R E
• the scheduling policy (non-preemptive or preemptive task);
• the services that are used by the task;
• the interrupt and error handling policy;
• the processor type.
The recommended values of the minimal task stack size are provided in
Section 15.5 Task Stack Size.
NOTE: If the task stack is less than the minimal value for the given configuration,
it may lead to unpredictable behavior of the task and to a system crash.
R E Q U I R E D
• TaskBasePage If this option is turned on, the task control
blocks are placed into the base page
memory. It increases the system
performance, since the CPU accesses
the base page faster than extended
memory. In this case, the user is
responsible for the necessary amount of
RAM in the base page for the desired
number of task control blocks.
A G R E E M E N T
4.8.2 Data Types
The OSEK OS establishes the following data types for the task
management:
N O N - D I S C L O S U R E
TaskStateType data type.
Only these data types may be used for operations with tasks.
TASK <TaskName> {
TYPE = <TaskType>;
PRIORITY = <TaskPriority>;
SCHEDULE = <TaskScheduling>;
ACTIVATION = <TaskMultiplyActivation>;
AUTOSTART = <TaskInitState>;
StackMethod = <TaskStackAssignment>;
};
The application definition file contains one such statement per task. The
A G R E E M E N T
ActivateTask Activates the task, i.e. put it from the suspended into the ready state
TerminateTask Terminates the task, i.e. put it from the ready into the suspended state
R E Q U I R E D
Examples of using the run-time services are provided in
Section 17.3.12 Examples for Task Management Services.
4.8.5 Constants
The following constants are used within the OSEK Operating System to
indicate task states:
A G R E E M E N T
• WAITING Constant of data type TaskStateType for task
state waiting
• READY Constant of data type TaskStateType for task
state ready
• SUSPENDED Constant of data type TaskStateType for task
state suspended
N O N - D I S C L O S U R E
4.8.6 Conventions
TASK ( TaskName )
{
...
}
Section 5. Scheduler
5.1 Contents
5.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
A G R E E M E N T
5.3 Scheduling Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.2 General
The algorithm deciding which task has to be started and triggering all
necessary OSEK Operating System internal activities is called scheduler.
It performs all actions to switch the CPU from one instruction thread to
another. It is either switching from task to task or from ISR back to a task.
The task execution sequence is controlled on the base of task priorities
(see section Section 4.6 Task Priorities) and the scheduling policy
used.
N O N - D I S C L O S U R E
The scheduler is activated whenever a task switch is possible according
to the scheduling policy. The principle of multitasking allows the
operating system to execute various tasks concurrently. The sequence
of their execution depends on the scheduling policy, therefore it has to
be clearly defined.
Scheduler also provides the endless idle loop if there is no task ready to
be running. It may occur, when all tasks are in the suspended or waiting
state until the awakening signal from an Interrupt Service Routine
occurs. In this case there is no currently running task in the system, and
the scheduler occupies the processor performing an endless loop while
the ISR awaits a task to be executed. It is possible to call a special user’s
hook from the scheduler idle loop. This property is turned on via the
system configuration option IdleLoopHook. If it is supported by
hardware, the scheduler’s idle loop may be replaced by an instruction
MOTOROLA Scheduler 65
Scheduler
R E Q U I R E D
that puts the CPU in low power mode to reduce power consumption. This
property is turned on via the system configuration option HCLowPower.
The scheduler has its own small stack (the scheduler’s stack) which is
needed for the endless idle loop. The stack size is specified by the user,
see section Section 13.3.1 Global System Attributes. The system
property UseMainStack can be specified by the user. In this case, the
same stack is used by the main() function, by the scheduler and by ISRs.
This option saves RAM consumption, but the user is responsible for the
required memory amount for the stack.
A G R E E M E N T
case, the scheduler uses a table of tasks instead of queues. This system
property can be turned on via the system configuration option
SimpleScheduler. By default this option is turned off.
66 Scheduler MOTOROLA
Scheduler
Scheduling Policy
R E Q U I R E D
5.3 Scheduling Policy
The scheduling policy being used determines whether execution of a
task may be interrupted by other tasks or not. In this context, a distinction
is made between full-, non- and mixed-preemptive scheduling policies.
The scheduling policy affects the system performance and memory
resources. In the OSEK Operating System, all listed scheduling policies
are supported, but in the case of the mixed-preemptive policy, each task
in an application may use only one of the three policies. It is defined via
the appropriate task property (preemptive/non-preemptive).
A G R E E M E N T
Note that the interruptibility of the system depends neither on the
Conformance Class, nor on the task type.
The desired scheduling policy is defined by the user via the system
configuration option SCHEDULE. The valid values are – NON, FULL,
MIXED.
N O N - D I S C L O S U R E
Non-preemptive scheduling imposes particular constraints on the
possible timing requirements of tasks. Specifically, the lower priority
non-preemptive section of a running task delays the start of a task with
higher priority, up to the next point of rescheduling. The time diagram of
the task execution sequence for this policy looks like the following:
MOTOROLA Scheduler 67
Scheduler
R E Q U I R E D
latency time
activation of task T1 for task T1
terminaton of task T2
A G R E E M E N T
Task T2 has lower priority than task T1. Therefore, it delays task T1 up
the point of rescheduling (in this case termination of task T2).
• Explicit wait call, if a transition into the waiting state takes place
(via the WaitEvent system service, Extended Tasks only).
In the non-preemptive system, all tasks are non-preemptive and the task
switching will take place exactly in the listed cases.
68 Scheduler MOTOROLA
Scheduler
Scheduling Policy
R E Q U I R E D
With full-preemptive scheduling, the latency time is independent of the
run time of lower priority tasks. Certain restrictions are related to the
increased RAM space required for saving the context, and the enhanced
complexity of features necessary for synchronization between tasks. As
each task can theoretically be rescheduled at any location, access to
data that are used jointly with other tasks must be synchronized.
A G R E E M E N T
activation of task T1 terminaton of task T1
N O N - D I S C L O S U R E
used for execution of different tasks on the same system, the resulting
policy is called “mixed-preemptive” scheduling. The distinction is made
via the task property (preemptive/non-preemptive).
MOTOROLA Scheduler 69
Scheduler
R E Q U I R E D
70 Scheduler MOTOROLA
Scheduler
Programming Issues
R E Q U I R E D
5.4.2 Run-time Services
The scheduler is not accessed by the user directly. The user can only
pass the CPU control to the scheduler by means of the Schedule system
service. This leads to task rescheduling.
A G R E E M E N T
occupation, before the corresponding call ReleaseScheduler is
performed. While the task occupies the scheduler, it has the highest
priority and, therefore, cannot be interrupted by other tasks (only ISRs
can get the CPU control during this period). Such programming practice
can be used for important critical sections of code.
GetResource( RES_SCHEDULER );
...
/* Critical section - this code cannot be interrupted by any other task */
...
ReleaseResource( RES_SCHEDULER ); /* End of the critical section */
N O N - D I S C L O S U R E
5.4.3 Scheduler Definition
OS <name> {
.....
SCHEDULE = MIXED;
NodeNumber = <NumberOfTasks>;
SchedStackSize = <SchedulerStackSize>;
MaxPrio = <NumberOfPriorities>;
NodeStackSize = <TaskNodeStackSize>;
.....
};
MOTOROLA Scheduler 71
Scheduler
R E Q U I R E D
A G R E E M E N T
N O N - D I S C L O S U R E
72 Scheduler MOTOROLA
R E Q U I R E D
User’s Manual — OSEK Operating System
6.1 Contents
6.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
A G R E E M E N T
6.3 ISR Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.4 ISR Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.5 Interrupt Flag Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.6 Local Variables Considerations . . . . . . . . . . . . . . . . . . . . . . . . 78
6.7 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.2 General
Interrupt processing is an important part of any real-time operating
system. An Interrupt Service Routine (ISR) is a routine which is invoked
from an interrupt source, such as a timer or an external hardware event.
N O N - D I S C L O S U R E
ISRs have higher priority than all tasks and the scheduler. Addresses of
ISRs should be pointed to in the vector table.
In OSEK OS, all ISRs should use the separate stack (ISR stack) which is
used only by ISRs during their execution. The size of the ISR stack is
defined by the user. At the beginning of an Interrupt Service Routine, the
user should switch to this stack using the system service EnterISR. After
the ISR completion, the corresponding service LeaveISR should be
performed to switch back to the previous stack. The instruction
sequence between the EnterISR and LeaveISR calls is considered as
ISR frame.
When interrupt occurs, either current stack can be used or the ISR stack.
The current stack is:
OS also controls the state of an interrupt mask. The user defines values
of the interrupt masks for disabling and enabling all interrupts, and the
default interrupt mask for task execution. See Section 13.3.3 Interrupt
Related Properties for details.
Interrupts cannot use any OS services except those which are specially
allowed to be used within ISRs. When using other services, the system
behavior will be unpredictable. In the Extended (debugging) status of the
Operating System, the error will be reported in such a case. See
1. If PreTaskHook/PostTaskHook user’s hooks are used (see Section 11.3 Hook Routines)
and GetTaskId directive is supported (see Section 17.3.9 GetTaskId) then OSEK OS supports
up to 127 levels of nested interrupts.
R E Q U I R E D
Section 6-1 Interrupt Management Services in the OSEK OS and
Section 17 System Services for details.
A G R E E M E N T
performed by the EnterISR service at the beginning of ISR. This stack is
used only by ISRs, and if nested interrupts occur after the stack has
been switched, they will use this stack too. Before leaving the ISR,
switching back to the interrupted task stack must be achieved by means
of LeaveISR.
The interrupt stack frame usually consists of the CPU registers, and
optionally some compiler-dependent ‘virtual’ registers. The CPU
registers are pushed onto the stack under hardware or software control.
In the latter case the compiler generates a stack frame by means of
adding special sequences of machine instructions before the first
statement in the function.
N O N - D I S C L O S U R E
Most compilers use function modifiers (like ‘interrupt’) to generate stack
frames. In turn, the ISR keyword, specified in OSEK (see
Section 6.7.4 Conventions), is a macro for this modifier.
ISRs of this type do not use any operating system service. These ISRs
do not use OS services EnterISR and LeaveISR, consequently, ISRs of
these type are executed on the current stack. In this case, if the ISR uses
the stack space for its execution, the user is responsible for the
appropriate stack size. Moreover, if interrupts are re-enabled inside the
ISR, nested interrupts are possible, which will use the same task stack.
The general recommendation for ISRs category 1 may be the following:
RULE: ISR category 1 cannot use any OS services. These ISRs must disable
interrupts internally (at the beginning of the routine).
management.
ISR( ISR_handler )
{
...
/* the code without any OS service calls */
...
}
ISR( ISR_handler )
{
/* OS internal EnterISR() call */
...
/* the code with allowed OS calls */
...
/* OS internal LeaveISR() call */
}
Inside the ISR, no rescheduling will take place. Rescheduling may only
take place on termination of the ISR if a preemptive task has been
interrupted.
R E Q U I R E D
6.4.3 ISR Category 3
In ISR category 3, the OSEK Operating System provides the ISR frame
to execute more complicated user code. The ISR frame is instructions
between OS services EnterISR and LeaveISR. Such ISRs are similar to
those of category 2, but the location of the ISR frame in the code
segment is application dependent and user defined. The code outside
the ISR frame can be used, e.g., to access global variables or hardware
registers. The user is responsible for operations outside the ISR frame,
since they could unproperly modify stack frame (see Section 6.6 Local
Variables Considerations), and interrupts may be enabled (see
A G R E E M E N T
Section 6.4.1 ISR Category 1). No OS service calls can be executed
outside the ISR frame.
ISR( ISR_handler )
{
/* user’s code */
...
EnterISR();
/* the code with allowed OS calls */
...
LeaveISR();
}
N O N - D I S C L O S U R E
RULE: In ISR category 3, all operations using OS services and/or with enabled
interrupts must be performed only inside the ISR frame.
mask which disables some interrupts and enables other ones. In the
interrupt definition statement, the user should select interrupt masks for
all interrupts disabled, all interrupts enabled and some desired medium
state (by default a task gets this interrupt mask when it is activated if it
does not have its own starting interrupt mask specified). The special
data type is defined within the OSEK Operating System to control
interrupt masks. The set of special OS attributes is introduced to
configure interrupt masks.
A G R E E M E N T
The EnterISR and LeaveISR functions assume that the stack frame is
defined on entry. Moreover, the stack pointer may be changed during the
execution of these functions. Thus, the use of local variables inside ISR
category 3 may lead to unpredictable behavior and a crash. Therefore,
the user is not permitted to use local variables inside ISR category 3.
Instead, the user may split the interrupt service routine into two
functions. The nested function should perform useful work, and may
have local variables. The outermost function should call the nested
N O N - D I S C L O S U R E
int __SciHandler(void)
{ /* The inner function with local variables */
char status; /* local variable to hold SCI status*/
int num; /* local variable to byte counter*/
... /* useful user’s code*/
}
R E Q U I R E D
The example of the wrong code – local variables are allocated on the
task stack, but the stack pointer is changed by EnterISR after, therefore
references to the variables are invalid:
int __SciHandler(void)
{ /* The inner function without local variables */
... /* useful user’s code*/
}
A G R E E M E N T
EnterISR(); /* Stack Pointer is changed ! */
num = __SciHandler();/* Perform useful work to handle
interrupt*/
LeaveISR();
}
N O N - D I S C L O S U R E
• EntryExitISR if the option is turned off, it is assumed
that there are no interrupts in the system
at all and the Operating System does not
have any interrupt handling mechanisms.
No interrupt management services are
implemented.
• InterruptMaskControl
if the option is turned off (while the
EntryExitISR option is turned on),
interrupt masks are not controlled by the
operating system. Services
EnableInterrupt, DisableInterrupt,
GetInterruptDescriptor are not
implemented.
• UnorderedExceptions
if the option is turned on, it is possible to
handle unordered exceptions. This
attribute is intended for MPC only.
The OSEK OS establishes the following data types for the task
management:
The only data types must be used for operations with interrupt masks.
R E Q U I R E D
Table 6-1. Interrupt Management Services in the OSEK OS
Service Name Description
Interrupt Management Services
Registers the switching to the interrupt level and switch context to
EnterISR
the ISR stack
LeaveISR Registers the leaving of the ISR level
Enables interrupts in accordance with the given logical interrupt
EnableInterrupt
descriptor
Disables interrupts in accordance with the given logical interrupt
DisableInterrupt
descriptor
A G R E E M E N T
GetInterruptDescriptor Returns the current state of interrupts
Services allowed for use in ISR
ActivateTask Activates the specified task (puts it into the ready state)
GetTaskState Gets state of the task
SetEvent Sets event for the task
GetEvent Gets event of the task
Sends an unqueued message in WithCopy configuration to the
SendMessage
specified task
Delivers data of an unqueued message in WithCopy configuration to
ReceiveMessage
the application message copy
GetMessageStatus Returns the current status of the message
GetAlarmBase Gets alarm base characteristics
N O N - D I S C L O S U R E
SetRelAlarm Sets relative alarm
SetAbsAlarm Sets absolute alarm
CancelAlarm Cancels alarm
GetAlarm Gets value in ticks before the alarm expires
CounterTrigger Increments a counter value
GetActiveApplicationMode Gets current application mode
6.7.4 Conventions
ISR( ISRName )
{
...
The keyword ISR is the macro for compiler specific interrupt function
modifier, which is used to generate valid code to enter and exit ISR.
DeclareISR( ISRName )
The same name shall be used for corresponding ISR object definition
(see Section 13.11 ISR Definition).
A G R E E M E N T
To define common ISR parameters like ISR stack size and predefined
interrupt masks the corresponding OS properties should be specified in
the configuration file.
OS <name> {
.....
IsrStackSize = <ISRStackSize>;
DisableInterruptMask = <DisableMask>;
EnableInterruptMask = <EnableMask>;
N O N - D I S C L O S U R E
InitialMask = <InitialMask>;
TaskLevelMask = <TaskMask>;
.....
};
ISR <ISRName>{
.....
CATEGORY = 2;
.....
};
R E Q U I R E D
6.7.6 Constants
A G R E E M E N T
N O N - D I S C L O S U R E
7.1 Contents
7.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
A G R E E M E N T
7.3 Access to Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.2 General
The resource management is used to coordinate concurrent accesses of
several tasks to shared resources, e.g. management entities
(scheduler), program sequences (critical sections), memory or hardware
areas. In general, the resource management is provided in all
Conformance Classes, but it is fully supported only beginning from the
BCC2 Conformance Class. In the lower Conformance Classes only the
scheduler is treated as the specific system resource which can be used
N O N - D I S C L O S U R E
by tasks.
• two tasks cannot occupy the same resource at the same time,
• priority inversion cannot arise while resources are used,
• deadlocks do not occur by use of these resources,
• access to resources never results in a waiting state.
• full-preemptive tasks,
which might be occupied by that task during its execution have been
released. Consequently, no situation occurs in which a task tries to
access an occupied resource. The special mechanism is used by the
OSEK Operating System to provide such behavior, see
Section 7.3.1 Priority Ceiling Protocol for details.
The waiting state is not admissible for Extended Tasks while a resource
is occupied. It means that the task occupying a resource is not allowed
to call the WaitEvent service.
R E Q U I R E D
7.3 Access to Resources
Before they are used, resources must be defined by the user at the
system configuration stage via the RESOURCE definition, see
Section 13.6 Resource Definition. Then the resource is declared in
the source file, where it will be used by means of a system declaration
statement DeclareResource (see Section 17.5 Resource
Management Services). After that, the task can occupy and release the
resource using the GetResource and ReleaseResource services. While
the resource is occupied, i.e., while the code between these services is
A G R E E M E N T
executed, this resource cannot be requested by another task.
N O N - D I S C L O S U R E
The priority ceiling protocol elevates the task requesting a resource to a
priority level. This priority can simply be calculated during system
generation. As shown in Section 7.2 General the Ceiling Priority is:
In the figure above, Task 1 has the highest priority and Task 4 has the
lowest Priority. The resource has a priority greater than or equal to the
Task 1 priority. When Task 4 occupies the resource, it gets a priority not
less than Task 1, therefore it cannot be preempted by ready Task 1 until
it releases the resource. Just after the resource is released, Task 4 is
N O N - D I S C L O S U R E
returned to its low priority and becomes ready, and Task 1 becomes the
running task. When Task 1, in its turn, occupies the resource, its priority
is also changed to the Ceiling Priority.
R E Q U I R E D
If a task wants to protect itself against preemptions by all other tasks, it
can occupy the scheduler exclusively. When it is occupied, interrupts are
received and processed normally. However, it prevents the rescheduling
of tasks.
NOTE: If task got the scheduler and tries to yield CPU via the Schedule service
then Schedule service returns immediately without doing anything.
A G R E E M E N T
7.4 Programming Issues
N O N - D I S C L O S U R E
on, the system will work faster. But this option
may be used only for debugged applications,
because errors related to incorrect access and
priority are not signalled. If this option is turned
on, less ROM and RAM are needed for
resources. But, if resource priorities have a
large difference (e.g. first resource has priority
1 and the second resource has priority 20) this
option does not lead to RAM saving.
• ResourceAccessCheck
the option defines whether E_OS_ACCESS
error code is returned by GetResource service
or not. If it is TRUE, then error code will be
returned in EXTENDED status based on task
definition in OIL-file. If the system has
The OSEK OS establishes the following data type for the resource
management:
A G R E E M E N T
The only data type must be used for operations with resources.
This call serves to occupy the resource (critical section of the code, assigned
GetResource(1)
to the resource)
Releases the resource assigned to the critical section (to leave the critical
ReleaseResource
section)
1. E_OS_ACCESS error code is not returned by GetResource service if more than 8 resources (including
RES_SCHEDULER) are defined in the application or FastResource configuration option is turned on or Re-
sourceAccessCheck configuration option is turned off.
RESOURCE <ResourceID> {
PRIORITY = <ResourcePriority>;
};
R E Q U I R E D
For more details see Section 13.6 Resource Definition.
A G R E E M E N T
N O N - D I S C L O S U R E
8.1 Contents
8.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
A G R E E M E N T
8.3 Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.4 Alarms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
8.5 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.2 General
The OSEK operating system comprises a two level concept to make use
of recurring events like periodic interrupt of timers, interrupt of the
sensors on rotating angles, or any recurring software events. To manage
such a situation, counters and alarms are provided by the OSEK
Operating System. The recurring events (sources) can be registered by
counters. Based on counters, the OSEK OS offers an alarm mechanism
N O N - D I S C L O S U R E
to the application software. Counters and alarms are provided by the
OSEK OS in all Conformance Classes. Counter concept and counter
management system services are based in the ‘OSEK Operating
System, Concept’ v. 1.00, September 1995 and ‘OSEK Operating
System, Application Program Interface’ v. 1.00, September 1995.
Task Task
8.3 Counters
Any event in the system can be linked with a counter, so that when the
event has occurred, the counter value is changed. A counter is identified
in the system via its symbolic name, which is assigned to the counter
statically at the configuration stage.
The maximum allowed counter value specifies the number after which
the counter rolls over. When a counter reaches its maximum allowed
possible value (or rolls over the predefined size - byte etc.), it starts
counting again from zero.
R E Q U I R E D
If an alarm should be set for value 5, the maximum allowed counter value
must be 6.
The user also defines the maximal size of all counters in the system -
they can be byte-, word- or longword-sized. This is defined via the
system properties CounterSize.
The conversion constant can be used to convert the counter value into
an appropriate user specific unit of measurement, e.g. seconds for
timers, angular degrees for rotating axles. The conversion is done by the
user’s code and this parameter can be treated as a counter-specific
A G R E E M E N T
reference value.
At least one counter always exists in the system. This counter is used as
a system timer (the internal system clock). The system timer is a
standard counter with the following additions:
N O N - D I S C L O S U R E
• the user defines the source of hardware interrupts for the system
counter.
In the system definition statement for the system timer the user should
define one of possible hardware interrupt sources. Parameters to tune
the hardware can be also defined by the user in this statement. This
possibility allows the user to exactly tune the system (see SECTION 15
Platform-Specific Features for details).
interrupt. In this case in ISR for the specified interrupt the service
CounterTrigger must be used to advance the counter.
NOTE: The system timer will not be triggered if the EntryExitISR property is
turned OFF!
application software processing the event should call the system service
CounterTrigger. This service must be called within the ISR frame
created by the EnterISR and LeaveISR services. It is not allowed to use
CounterTrigger in ISR category 1 (see section Section 6.4 ISR
Categories).
The user is free to assign one source exactly to one counter (1:1
relationship), several sources to one counter (n:1 relationship), or one
source to several counters (1:n relationship), see Figure 8-1. Meaning
that it is possible to advance the same counter in different software
routines.
8.4 Alarms
The alarm management is built on top of the counter management. The
alarm management allows the user to perform link task activation or
R E Q U I R E D
event setting to a certain counter value. These alarms can be defined
as either single (one-shoot) or cyclic alarms.
The OSEK OS allows the user to set alarms (relative or absolute), cancel
alarms and read information out of alarms by means of system services.
Alarm is referenced via its symbolic name which is assigned to the alarm
statically at the configuration stage.
A G R E E M E N T
60 times’, or
– ‘Set a certain event, after the counter has reached a value of
90’.
The counter addressed in the first example might be derived from a timer
which is advanced every second. The task in the example is then
activated every minute. The counter addressed in the second example
might be derived from a rotating axle. The event is set on a 90 degree
angle.
Alarms are defined statically as with all other system resources. The
N O N - D I S C L O S U R E
assignment of alarms to counters, as well as the action to be performed
when an alarm expires (task and event), are also defined statically. An
application can use an alarm after it has been defined and assigned to a
counter. Alarms may be either in the stop state or running state. To run
an alarm, the special system services are used, which set dynamic
alarm parameters to start it.
counter will roll over and count until the specified value. If the
specified value is greater than the current value, the alarm will
expire just after the counter reaches the desired number. This is
illustrated by Figure 8-2. In the latter case, the total time until the
alarm expires is the sum of T1 and T2.
T1
specified current
0 absolute value counter value
N O N - D I S C L O S U R E
T2 T1
R E Q U I R E D
8.5 Programming Issues
The following system configuration options affect the counter and alarm
management:
A G R E E M E N T
valid values are 8, 16 and 32 which conform to
the byte, word or long word size of counters.
• Alarms This option defines whether alarms are
provided by the OS or not.
• AlarmList If this option is turned on, the running alarms
are linked into a list which decreases the time
for alarm handling.
• AlarmDeltaList If this option is turned on, the running alarms
are linked into an ordered alarm delta-list which
significantly decreases the time for
CounterTrigger service if too many alarms are
N O N - D I S C L O S U R E
connected with the same counter (more than
10). The time for alarm management services
will be increased. Note that this option will be
turned off if the AlarmList option is turned on.
• CyclicAlarm If this option is turned on, the cyclic alarms are
supported. Otherwise, no one alarm may be
cyclic, which decreases RAM usage for alarm
control blocks as well as decreasing code
usage, and advances timing of alarms services.
This option is turned on by default.
• MinAlarmRAM If this option is turned on, the alarm handling is
optimized for memory (RAM). Otherwise, alarm
handling is optimized for speed. When turned
All fields have the data type TickType. The following code may illustrate
usage of this data type:
CtrInfoType CntData;
TickType maxV, minC, cons;
GetCounterInfo( CntID, &CntData );
maxV = CntData.maxallowedvalue;
minC = CntData.ticksperbase;
cons = CntData.mincycle;
• CtrInfoRefType this data type references data corresponding to
the data type CtrInfoType.
R E Q U I R E D
• AlarmBaseType this data type represents a structure for storage
of alarm characteristics. It is the same as
CtrInfoType;
• AlarmBaseRefType
this data type references data corresponding to
the data type AlarmBaseType;
• AlarmType the data type represents an alarm element.
A G R E E M E N T
To generate a counter in an application, the COUNTER definition is
used, it looks like the following:
COUNTER <CounterID> {
MINCYCLE = <mincycle>;
MAXALLOWEDVALUE = <maxallowedvalue>;
TICKSPERBASE = <ticksperbase>;
};
OS <name> {
.....
SysTimer = <SysTimerSupport>;
N O N - D I S C L O S U R E
HardwareType = <TypeOfTimer>;
Prescaler = <PrescalerDefined>;
PrescalerValue = <PrescalerValue>;
TimerModulo = <TimerModuloDefined>;
TimerModuloValue = <TimerModuloValue>;
.....
};
ALARM <AlarmID> {
ACTION = <Acion>;
COUNTER = <CounterID>;
TASK = <TaskID>;
[ EVENT = <Event>; ]
};
OSEK OS grants a set of services for the user to manage counters and
alarms. Detailed descriptions of these services are provided in
Section 17 System Services. Here only a brief list is given.
R E Q U I R E D
Examples of the run-time service usage are provided in
Section 17 System Services.
8.5.5 Constants
• OSMAXALLOWEDVALUE
maximum possible allowed value of the
A G R E E M E N T
system timer in ticks;
• OSTICKSPERTIME, number of ticks that are required to reach
10 OSTICKPERBASE milliseconds in the
system counter;
• OSTICKDURATION duration of a tick of the system counter in
nanoseconds;
• OSMINCYCLE minimum allowed number of ticks for a
cyclic alarm (only for system with
Extended Status).
N O N - D I S C L O S U R E
Section 9. Events
9.1 Contents
9.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
A G R E E M E N T
9.3 Events and Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
9.4 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
9.2 General
Within the OSEK operating system, tasks can be synchronized via
occupation of a resource (see Section 7 Resource Management).
Another means of synchronization is the event mechanism, which is
provided for Extended Tasks only. Special fields in the task node of an
Extended Task are provided for event management in the OSEK OS
(see Section 4.7.2 Task Control Block). Events are the only
mechanism allowing a task to enter the waiting state.
N O N - D I S C L O S U R E
An event is an object managed by the OSEK Operating System, which
is able to store binary data. The interpretation of the event is up to the
user. Examples are: the signalling of a timer’s expiry, the availability of a
resource, the receipt of a message, etc.
Within the operating system, events are not independent objects, but
allocated to Extended Tasks. Each Extended Task has a definite
number of events – 8 or less (in fact, the byte size is used for event
management in the current OSEK OS implementation.). Events are
represented by two event masks – byte-sized fields in the task node
(See Section 4.7.2 Task Control Block). One field is the mask of
events the task is waiting for. This mask can be set and cleared only by
the task-’owner’ (a ‘private’ mask). The second field (a ‘public’ mask)
contains the mask of the events, which are set for the task by other
tasks. When activating an Extended Task, all its events are cleared.
An alarm can also be set for an Extended Task, which sets an event at
a certain time. Thus, the Extended Task can delay itself (see example in
Section 17.7.7 Examples of Using Events).
case. On the other hand, any task or ISR can set an event for an
Extended Task, and thus inform the appropriate Extended Task (its
identification must be known) about any status change via this event.
R E Q U I R E D
Extended Tasks are in the waiting state if an event for which the task is
waiting has not occurred. If an Extended Task tries to wait for an event
and this event has already occurred, the task remains in the running
state.
A G R E E M E N T
Thereafter Task 1 waits for this event again and the scheduler continues
execution of Task 2.
Scheduler
Event of
Extended task 1 set
reset reset
Extended task 1
waiting running reset event wait for event waiting
Extended task 2
running set event ready running
N O N - D I S C L O S U R E
Figure 9-1. Synchronization by events in case of full-preemptive
scheduling
Scheduler
Event of
Extended task 1 set
reset reset
Extended task 1
waiting ready reset event running wait for event waiting
Extended task 2
running set event rescheduling ready running
A G R E E M E N T
The OSEK Operating System establishes the following data types for the
event management:
The only data types must be used for operations with events.
EVENT <Event> {
R E Q U I R E D
MASK = 0x01;
};
A G R E E M E N T
OSEK OS grants a set of services for the user to manage events. A
detailed description of these services is provided in Section 17.7 Event
Management Services. Here only a brief list is given.
SetEvent Sets events of the given task according to the event mask
ClearEvent Clears events of the calling task according to the event mask
WaitEvent Transfers the calling task into the waiting state until specified events are set
N O N - D I S C L O S U R E
Examples of the run-time services usage are provided in section
Section 17.7 Event Management Services.
Note that it is possible to use bits in memory fields assigned for events
for some internal task’s needs as bit flags. In case of using events in the
system in every Extended task’s control block special fields are created.
If a task uses less than eight events, it is possible to use SetEvent and
ClearEvent system services with appropriate masks to manipulate the
internal task’s bit flags.
DeclareTask( TASK_A )
DeclareTask( TASK_C )
TASK( TASK_A )
{
EventMaskType x, y, z1, z2;
z1 = Z1_FLG; z2 = Z2_FLG;
int speed;
A G R E E M E N T
...
if (speed == LIMIT)
{
x = X_FLG;
SetEvent( TASK_A, x );
}
In the example the task uses four most significant bits of the event field
as its internal bit flags. Least significant bits are free and they can be
N O N - D I S C L O S U R E
used for ‘external’ OSEK OS events. But such approach requires more
attention from the user to avoid occasionally changing of ‘internal’ events
instead of ‘external’ ones and visa versa.
Note that access to that binary data is performed only via the system
services for event management.
10.1 Contents
10.2 Message Concept. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
A G R E E M E N T
10.3 Unqueued Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
10.4 Queued Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
10.5 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
N O N - D I S C L O S U R E
• Unqueued Messages and
• Queued Messages
In OSEK OS, message objects are referenced by tasks via the unique
identifiers defined by the user at the configuration stage.
OSEK supports two types of communication between tasks: 1:1 and 1:N
A G R E E M E N T
communication.
R E Q U I R E D
Table 10-1. Features of the Message Concept
Unqueued Message QueuedMessage
A G R E E M E N T
OSEK OS communication services provide all means for local message
transfer within single ECU. To transfer data over the network, the OSEK
Communication System (COM) will be used, which is designed to handle
all other types of communication through the network. And OSEK OS
communication services provide an interface for application tasks to
exchange data. Thus, messages serve as interface for both ECU
internal and network communication. Uniform services with identical
interfaces are offered (network transparency).
N O N - D I S C L O S U R E
Tasks can have three various access type to Unqueued Messages –
read only (receive), write only (send) and full read/write access. The
send operation overwrites the current value of a message, i.e.
Unqueued Messages are not buffered. The receive operation reads the
current value of a Unqueued Message whereby the message data is not
consumed.
body directly via de-referencing of the pointer and writing the data
at the pointer address, and the task-receiver uses the message
body by means of de-referencing the pointer and reading the data.
The operating system doesn’t provide atomic behavior of the
send-receive operations, and this consistency is to be provided by
the user’s code.
R E Q U I R E D
To have Unqueued Messages in the system the configuration option
UnqueuedMessages must be turned on.
A G R E E M E N T
During the read operation the message item is copied from the FIFO
area at the read pointer into the receiving task space. The data is copied
consistently, i.e. the operating system provides atomic behavior of the
send-receive operations. The FIFO area is circular. It is illustrated in
Figure 10-1. Message “msg1” is consumed from the Queued Message
object by a task, and other message items are “moved” in the Queued
MO towards the top (in fact, read and write pointers are changed). After
the message item “msg1” was consumed, new message “msg5” is
written by a task at the empty location (the last one). If an Queued
Message object has no memory capacity left to store the new message,
the oldest message is overwritten - in Figure 10-1 “msg2” is overwritten
by the message item “msg6” in spite that “msg2” has not been
N O N - D I S C L O S U R E
consumed. The overwriting process is indicated both to sender and
receiver in systems with Extended Status by means of return codes
while send or receive services are executed by a task.
“msg1” is consumed
by a task “msg1”
read read read
pointer pointer pointer
... “msg2” “msg2”
write
“msg2” “msg3” pointer “msg3”
1 2 3
“msg5” “msg6”
New message “msg5” New message “msg6”
is written by a task into will overwrite “msg2” of
the Queued MO the Queued MO
R E Q U I R E D
• UnqueuedMessages This option allows Unqueued Messages
in the system;
• UnqueuedMsgDefaultValue
This option allows Unqueued Messages
to have default values;
• QueuedMessages This option allows Queued Messages in
the system;
• QueuedMsgOneToN If this option is turned on, 1:N Queued
Messages are allowed;
A G R E E M E N T
• ActivateOnMsg If this option is turned on task activation
on message arrival is supported;
• AlarmOnMsg If this option is turned on an alarm can be
linked to message arrival;
• SetEventOnMsg If this option is turned on event setting is
allowed on message arrival.
10.5.2 Identifiers
The following names are used in the OSEK Operating System for work
with messages:
N O N - D I S C L O S U R E
• SymbolicName This is an unique name representing a
message. It only can be used in
conjunction with calls of the message
service. A SymbolicName need not be a
data type. Variables or constants of
SymbolicName can be declared or used.
• AccessName This is a unique name defining access to
a message object. Depending on the
chosen configuration, a distinction is
made between the following AccessName
scheme:
WithCopy configuration:
A application variable exists as a local
copy of the message. The name of the
MESSAGE <MsgName> {
ACTION = <MessageAction>;
TYPE = <MessageType>;
ITEMTYPE = <type>;
ITEMS = <BufferSize>;
ALARMRESETTIME = <TimeOut>;
ALARMRESET = <AlarmId>;
StartupAlarm = <Start>;
N O N - D I S C L O S U R E
TASK = <TaskId>;
EVENT = <EventMask>;
ReceiverNum = <NumberOfReceivers>;
DefaultValue = <InitialValue>;
};
R E Q U I R E D
10.5.4 Run-time Services
OSEK OS grants a set of services for the user to manage tasks. Detailed
descriptions of these services are provided in section
Section 17.8 Communication Management Services. Here only a
brief list is presented.
A G R E E M E N T
ReceiveMessage Gets the unqueued message
N O N - D I S C L O S U R E
Messages are identified via a symbolic name. This identifier is used for
references to the message when the system service is used.
For example, if the user defines the message MsgA having type int, then
user’s code may access message using the following statements:
OSMSGMsgA _MsgA;
For example, if the user defines the WithoutCopy message MsgB, having
A G R E E M E N T
the type int, then user’s code may access message using the following
statements:
OSMSGMsgB*_MsgB = (OSMSGMsgB*)&OSMsgB->msg;
/* Source C-file */
const int myMsgADefValue = 0; /* MsgA default value */
/* Configuration OIL-file */
N O N - D I S C L O S U R E
MESSAGE MsgA {
TYPE = UNQUEUEDMESSAGE;
ITEMTYPE = "int";
ITEMS = 1;
DefaultValue = "&myMsgADefValue";
};
11.1 Contents
11.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
A G R E E M E N T
11.3 Hook Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
11.4 Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
11.5 Start-up Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
11.6 Application Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
11.7 System Shutdown. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
11.8 Programming Issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
11.2 General
The OSEK Operating System provides the user with tools for error
N O N - D I S C L O S U R E
handling and simple debugging at run time. These are special hook
routines with names specified by OSEK OS that are to be developed by
the user. In this section, error handling at the system configuration stage
is not considered; it is described in Section 12 System Configuration.
R E Q U I R E D
• PreTaskHook – this hook is called before the operating system
enters the context of the task. This hook is called from the
scheduler when it passes control to the given task. It may be used
by the application to trace the sequences and timing of the tasks’
execution.
• PostTaskHook – This hook is called after the operating system
leaves the context of the task. It is called from the scheduler when
it switches from the current task to another. It may be used by the
application to trace the sequences and timing of tasks’ execution.
A G R E E M E N T
• StartupHook – This hook is called after the operating system
startup and before the scheduler is running. It may be used by the
application to perform initialization actions, task activation, alarm
setting.
• ShutdownHook – This hook is called when the service ShutdownOS
has been called. It is called before the Operating System shuts
down itself.
• IdleLoopHook – This hook is called from scheduler idle loop (see
Section 5.2 General). It is not possible to call any OSEK OS
directives from this hook. Hardware dependent code (like
manipulation with COP registers) may be placed here.
N O N - D I S C L O S U R E
with the help of hook routines OSPreTask and OSPostTask. The user
can set time stamps enabling him to trace the program execution at the
following locations before calling operating system services:
ActivateTask -- -- -- allowed --
A G R E E M E N T
TerminateTask -- -- -- -- --
ChainTask -- -- -- -- --
Schedule -- -- -- -- --
EnterISR -- -- -- -- --
LeaveISR -- -- -- -- --
EnableInterrupt -- -- -- -- --
DisableInterrupt -- -- -- -- --
DeclareResource -- -- -- -- --
GetResource -- -- -- -- --
ReleaseResource -- -- -- -- --
SetEvent -- -- -- -- --
ClearEvent -- -- -- -- --
WaitEvent -- -- -- -- --
InitCounter -- -- -- -- --
CounterTrigger -- -- -- -- --
AdvanceCounter -- -- -- -- --
GetCounterValue -- -- -- -- --
R E Q U I R E D
Table 11-1. OSEK OS system services for hook routines
Hook routines
Service Error PreTask PostTask Startup Shutdown
Hook Hook Hook Hook Hook
GetCounterInfo -- -- -- -- --
A G R E E M E N T
SetRelAlarm -- -- -- -- --
SetAbsAlarm -- -- -- -- --
CancelAlarm -- -- -- -- --
SendMessage -- -- -- -- --
allowed for
ReceiveMessage unqueued -- -- -- --
messages
GetMessageResource -- -- -- -- --
ReleaseMessageResource -- -- -- -- --
GetMessageStatus allowed -- -- -- --
N O N - D I S C L O S U R E
StartOS -- -- -- -- --
ShutdownOS -- -- -- -- --
1. It may happen that currently no task is running. In this case the service returns the task Id INVALID_TASK.
2. It may happen that currently no task is running. In this case the service returns E_NOFUNC return value if OSEK
OS has the Extended Status.
NOTE: It is not possible to call any OSEK OS services from IdleLoopHook hook
routine.
The OSEK OS error service is called with a parameter that specifies the
error. It is up to the user to decide what to do, depending on which error
has occurred. The OSEK Operating System specifies the following
errors:
R E Q U I R E D
Table 11-2. OSEK OS Error codes
Error Name Value Description
Common Error Codes
E_OK 0 No error, successful completion
E_OS_ACCESS 1 Access to the service/object denied
E_OS_CALLEVEL 2 Access to the service from the ISR is not permitted
E_OS_ID 3 The object ID is invalid
E_OS_LIMIT 4 The limit of services/objects exceeded
E_OS_NOFUNC 5 The object is not used, the service is rejected
A G R E E M E N T
E_OS_RESOURCE 6 The task still occupies the resource
E_OS_STATE 7 The state of the object is not correct for the required service
E_OS_VALUE 8 A value outside of the admissible limit
E_OS_SYS_STACK 10 Internal stack overflow
E_COM_BUSY 1 Message in use by application task/function
E_COM_ID 3 Invalid message name passed as parameter
E_COM_LIMIT 4 Overflow of FIFO associated with queued messages
Rejected service call, message object locked due to a pending
E_COM_LOCKED 7
operation
E_COM_NOMSG 9 No message available
N O N - D I S C L O S U R E
System can be intercepted to a large extent via the Extended Status of
the Operating System, and displayed. This results in an extended
plausibility check on calling OS services.
R E Q U I R E D
(Re-)Start
OS executes
hardware- first user
call to operation OS executes OS kernel
specific task is
StartOS system StartupHook is running
initialization code running
initialization code
A G R E E M E N T
Figure 11-1. System startup in the OSEK OS
After returning from the StartupHook hook routine, the operating system
enables interrupts according to INITIAL_INTERRUPT_DESCRIPTOR
(see Section 6.7.6 Constants), and starts the scheduler.
N O N - D I S C L O S U R E
NOTE: Application mode consists of own set of tasks. All other OSEK OS
system objects like Alarms, Messages, Stack Pools etc. are shared
between different application modes.
R E Q U I R E D
returns, the operating system jumps to the next statement following the
initial call to StartOS. After this, the OSEK OS may be started again in a
specified application mode.
NOTE: After the return from ShutdownOS service all interrupts will be disabled.
A G R E E M E N T
The following configuration options affect error handling and hook
routines:
N O N - D I S C L O S U R E
• StartupHook If this option is turned on, the StartupHook
is called by the system at the end of the
system initialization
• ShutdownHook If this option is turned on, the
ShutdownHook is called by the system
when the OS service ShutdownOS has
been called
• IdleLoopHook If this option is turned on, the
IdleLoopHook is called from scheduler
idle loop
12.1 Contents
12.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
A G R E E M E N T
12.3 Application Configuration File . . . . . . . . . . . . . . . . . . . . . . . . .134
12.4 OIL Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
12.2 General
The OSEK Operating System is fully statically configured one. All
system properties, the number of system objects and their parameters
(characteristics of tasks, counters, alarms, messages, etc.), run time
behavior are defined by the user. Such approach allows the user to
create various range of applications with exactly defined characteristics.
Different memory and performance requirements can be easily satisfied
with such modular approach.
N O N - D I S C L O S U R E
All application parameters are defined in the special configuration file.
This file must conform some grammar rules. It is processed by the
separate System Generator utility (SG) 1. The System
Generator analyzes statements in the configuration file and builds output
C-language files needed to compile and link an application with the
specified features. During its execution SG reports to the user about the
errors. The System Generator produces header and source code files
that defines all properties and objects in terms of the C language. These
files are to be compiled and linked together with the user’s source code.
1. One version of SG is delivered - the 32-bit version (‘sysgen.exe’) for Windows NT and Win-
dows 95.
files and one source file. These files provides the code for all system
tables, descriptors, arrays etc. both in ROM and RAM according to the
user specified application configuration.
All keywords, attributes, object names, and other identifiers are case-
sensitive.
The OIL file contains two parts - one for the definition of implementation
specific features (Implementation Definition) and another one for the
definition of the structure of the application located on the particular CPU
(Application Definition).
In the very beginning of an OIL file the number of the version of OIL is
indicated. The keyword OIL_VERSION is used for this purpose. Two OIL
R E Q U I R E D
versions are supported at the moment - version 2.0 corresponds to the
Standard OIL format and version 2.0e corresponds to the Extended OIL
format. For example:
OIL_VERSION = "2.0e";
A G R E E M E N T
mode with name ‘Mode’ by default). The Standard OIL is considered to
be a part of OSEK OS specification v.2.0. It strictly defined by the
“OSEK/VDX System Generation OIL: OSEK Implementation
Language”, version 2.0, OSEK group, 16.12.1997.
N O N - D I S C L O S U R E
12.4.4 Implementation Definition
The user can limit the given set of values for object attributes (e.g.
restrict the possible OS conformance classes).
IMPLEMENTATION <name> {
<object_descriptions>
N O N - D I S C L O S U R E
};
All objects within Implementation Definition part are described using the
same syntax.
<object_type> {
<property_definitions>
};
R E Q U I R E D
<attr_type> [ WITH_AUTO ] [ <attr_range> ] <attr_name> [ = <default_value>
] ;
The attribute type and attribute value range (if it exists) shall be defined.
The range of attribute values can be defined in two ways: either the
minimum and maximum allowed attribute values are defined (the [0..12]
style) or the list of possible attribute values are presented (like C
enumeration type).
A G R E E M E N T
value AUTO and the possibility of automatic assignment.
Data types defined for OIL are listed below. Note that these data types
are not necessarily the same as the corresponding C data types.
N O N - D I S C L O S U R E
Of-Line) in the string then the next line is the continuation of the
previous one. This is identical to the same rule for long text strings
in the C language.
The reference type is taken from the referenced object (e.g. a reference
to a task shall use the TASK keyword as reference type). A reference
can ‘point to’ any system object.
<object_type> <object_name> {
<property_definitions>
};
All assignments are made via the ‘=’ operator. Each statement ends with
semicolon - ‘;’ like in the C language. A reference is represented as a
reference type keyword assigned with a name of the object referenced.
If multiple reference pointed to the set of object the object names are
listed via comma inside the curly brackets, for example task referencing
to own events:
R E Q U I R E D
12.4.5.2 Include Directive
#include <filename.oil>
#include "[path]filename.oil"
A G R E E M E N T
variable. The angle-bracket form means that a header file is being
looked for first along the path specified by the “/I” command-line option,
then along paths specified by the special environment variable.
12.4.5.3 Comments
An OIL file may contain comments. The ’/*’ and ’//’ characters define the
start of a comment. Any characters after ’//’ are considered as a
comment and the end of line (EOL) terminates the comment. Any
characters after ’/*’ are considered as comments and the end of the
comment is defined by ’*/’. Nested comments are not allowed in OIL.
N O N - D I S C L O S U R E
12.4.5.4 File Structure
Any file in the Standard OIL format describes an application for a single
CPU and, in general, must have the following structure:
OIL_VERSION = <version>;
IMPLEMENTATION <name> { // Implementation definition
<OBJECT_TYPE> {
...list of implementation specific object attributes...
};
...
};
};
... list of objects ...
}
13.1 Contents
13.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
A G R E E M E N T
13.3 OS Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
13.4 Task Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156
13.5 Stack Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159
13.6 Resource Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160
13.7 Event Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
13.8 Counter Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
13.9 Alarm Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163
13.10 Message Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164
13.11 ISR Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167
13.12 Different Application Modes Definition . . . . . . . . . . . . . . . . . .168
N O N - D I S C L O S U R E
13.2 General
All objects that are controlled by the Operating System - tasks,
resources, alarms, messages, counters, ISRs and even the OS itself -
are considered as system objects. Each of them has its unique
characteristics defined by the user. To specify parameters for each
system object the special statements are used for each object. All
statements are described below in detail.
memory areas. If the user explicitly specifies the address then the
symbolic name (e.g. MyTaskStack) should be provided in the
corresponded position. This name must be defined in a user’s file (e.g.
an array can be defined for memory area) and declared as external
name before the generated source files will be used. Such techniques is
demonstrated in sample application, see Apppendix A Sample
Application.
13.3 OS Definition
A G R E E M E N T
Description:
OS sampleOS {
CC = BCC2;
STATUS = STANDARD;
};
Below the list of all additional attributes which can be defined for an
N O N - D I S C L O S U R E
object of the OS type follows. Brief explanations are provided. This list is
divided into parts which correspond to appropriate system objects.
• OSVERSION (ENUM)
Defines the version of OSEK OS specification which OS supports.
This attribute can have values 1 or 2. In the current OSEK OS
implementation it is necessary to specify 2 as OSVERSION value.
• TargetMCU (ENUM)
Specifies the CPU type. Possible values are HC08, HC12,
CPU32, MPC, MCORE and WINNT.
R E Q U I R E D
• DEBUG_LEVEL (ENUM)
Specifies the ORTI support in OS. The attribute can have values
0 or 1. If the system has the DEBUG_LEVEL = 0 the static ORTI
support is switched off. If the system has the DEBUG_LEVEL = 1
this mode is considererd to be a debudding mode (see
Section 18 ORTI Implementation for the details).
• ORTIRunningTask (BOOLEAN)
Specifies that the running task identification in run-time support
will be used. This attribute will be ignored if DEBUG_LEVEL = 0
(see Section 18 ORTI Implementation for the details).
A G R E E M E N T
• ORTICurrentService (BOOLEAN)
Specifies that the OSEK OS system calls identification in run-time
support will be used. This attribute will be ignored if
DEBUG_LEVEL = 0 (see Section 18 ORTI Implementation for
the details).
• HCBasePage (BOOLEAN)
Defines that the base memory page will be used for system
variables. This option may reduce the OS code size by means of
the direct addressing mode usage when possible. This is a target
specific attribute.
• HCBankCode (BOOLEAN)
N O N - D I S C L O S U R E
Specifies that the banked memory model support will be used.
This is a target specific attribute. Defines that memory bank
switching is supported by the system.
• HCAltRegISR (BOOLEAN)
This attribute is only applicable if TargetMCU is MCORE. It
specifies that Alternative Register File will be used for ISR
processing.
• CC (ENUM)
The CC attribute specifies the Conformance Class which is
supported by the OS. This attribute has the type ENUM. The
possible values are the following:
– BCC1
– BCC2
– ECC1
– ECC2
– AUTO
• STATUS (ENUM)
The STATUS attribute specifies the debugging ability of OS. If the
system has the EXTENDED status some additional checks are
performed to detect run-time errors. This mode is considered to be
a debugging mode. Standard status OS performs only very limited
set of checks, the performance is increased and the amount of
consumed memory is decreased. This attribute has the type
A G R E E M E N T
R E Q U I R E D
• EntryExitISR (BOOLEAN)
If the attribute is FALSE it is assumed that there are no interrupt
service routines in the system at all and the Operating System
does not have any interrupt handling mechanisms. Interrupt
management services are not supported.
• InterruptMaskControl (BOOLEAN)
If the attribute is FALSE (while the EntryExitISR attribute is TRUE)
interrupt masks are not controlled by the operating system.
Services EnableInterrupt, DisableInterrupt, GetInterruptDescriptor
are not supported.
A G R E E M E N T
• NodeNumber (INT)
The attribute of the type INT specifies the maximum number of
tasks in the non-suspended state, available in the system. In fact,
this parameter specifies the number of task control blocks,
allocated in the system.
• SchedStackSize (INT)
The attribute of the type INT specifies the size (in bytes) of the
scheduler’s idle loop stack. It should not be less than the interrupt
stack frame. If the system property UseMainStack is set this
attribute (and SchedStackAddress also) is ignored.
• SchedStackAddress (STRING)
N O N - D I S C L O S U R E
The attribute of the type STRING specifies the bottom of the
scheduler stack. This address can be defined explicitly to provide
a way to optimize stack allocation. In this case it is presented as
an array of characters named by SchedStackAddress attribute
value. This array should be defined in a user’s source file and
declared in a user’s header which is to be included into the system
configuration source file (see Section 14.3.2 Source Files).
• MaxPrio (INT)
The attribute of the type INT specifies the number of task priorities
in the system. This parameter is ignored if the attribute
SimpleScheduler is TRUE, since in this case it must be equal to
the number of tasks.
• NodeStackSize (INT)
The attribute of the type INT specifies the size of the stack (in
bytes) per each task node. The total size of the memory area for
R E Q U I R E D
• ExtendedContext (BOOLEAN)
Defines whether OS has to support task context extension or not.
Valid only if the target MCU has the corresponding hardware
support (MPC505) or it is necessary due to specific compiler
behavior (HC08).
• UseMoveBlockInstruction (BOOLEAN)
Defines whether OS has to use CPU memory move block
instructions or not. This attribute is intended for MPC only.
A G R E E M E N T
13.3.2 Task Related Attributes
• SCHEDULE (ENUM)
The SCHEDULE attribute specifies the kinds of scheduling which
are supported by the OS. This attribute allows for a cross-check of
the requirements of the tasks and the capabilities offered by the
operating system. The possibility of automatic assignment for this
attribute is supported. The possible values are the following:
– NON
– FULL
– MIXED
N O N - D I S C L O S U R E
– AUTO
• MultiplyActivation (BOOLEAN)
The attribute controls the multiply activation ability for
Conformance Classes. If the attribute is FALSE multiply activation
is disabled for tasks.
• TaskIndexMethod (BOOLEAN)
If the attribute is TRUE then the intermediate vector of the pointers
to tasks control blocks is used (fast and deterministic access to
task nodes).
• NodeStack (BOOLEAN)
The attribute defines the presence of task node stacks in the
system. If it is FALSE there are no task node stacks implemented.
• StackPool (BOOLEAN)
The attribute defines the presence of stack pools in the system. If
it is FALSE there are no stack pools implemented.
• PersistentNode (BOOLEAN)
If the attribute is TRUE a persistent task control block may be
assigned to the task.
• PersistentStack (BOOLEAN)
If the attribute is TRUE a persistent stack buffer may be assigned
to the task.
A G R E E M E N T
• TaskOwnStack (BOOLEAN)
The attribute defines that a task may have its own stack.
• UseSameContext (BOOLEAN)
If the attribute is TRUE the same run time context frame is used
both for non-preemptive and preemptive tasks in mixed-
preemptive systems.
• TaskBasePage (BOOLEAN)
If the attribute is TRUE, the task control blocks are placed into the
base page memory. It increases the system performance since
CPU accesses the base page faster than extended memory. In
this case the user is responsible for the needed amount of RAM in
the base page for the desired number of task nodes.
N O N - D I S C L O S U R E
• ChainTaskItself (BOOLEAN)
The attribute can be set as FALSE if no tasks that chain itself. It
decreases the task control block size.
• NonPreemptCtxRegNum (INT)
The attribute specifies the number of extended registers to be
included into non-preemptive task context. It should contain value
from 1 till 18. Intended for MPC505 only. Valid only if
ExtendedContext = TRUE.
• SaveNonPreemptCtxExt (STRING)
The attribute specifies the assembler macro for saving extended
registers into non-preemptive task context. It should be a STRING
which contains inline assembler statements for saving extended
registers. Intended for MPC505 only. Valid only if
ExtendedContext = TRUE.
R E Q U I R E D
• RestoreNonPreemptCtxExt (STRING)
The attribute specifies the assembler macro for restoring
extended registers from non-preemptive task context. It should be
a STRING which contains inline assembler statements for
restoring extended registers. Intended for MPC505 only. Valid
only if ExtendedContext = TRUE.
• PreemptCtxRegNum (INT)
The attribute specifies the number of extended registers to be
included into preemptive task context. It should contain value from
1 till 18. Intended for MPC505 only. Valid only if ExtendedContext
A G R E E M E N T
= TRUE.
• SavePreemptCtxExt (STRING)
The attribute specifies the assembler macro for saving extended
registers into preemptive task context. It should be a STRING
which contains inline assembler statements for saving extended
registers. Intended for MPC505 only. Valid only if
ExtendedContext = TRUE.
• RestorePreemptCtxExt (STRING)
The attribute specifies the assembler macro for restoring
extended registers from preemptive task context. It should be a
STRING which contains inline assembler statements for restoring
extended registers. Intended for MPC505 only. Valid only if
N O N - D I S C L O S U R E
ExtendedContext = TRUE.
• IsrStackSize (INT)
The attribute of the type INT specifies the size (in bytes) of the ISR
stack. If the attribute UseMainStack is TRUE this attribute (and
ISRStackAddress also) can be omitted.
• IsrStackAddress (STRING)
The attribute of the type STRING specifies the bottom of the ISR
stack. This address can be defined explicitly to provide a way to
optimize stack allocation. In this case it is presented as an array of
characters named by IsrStackAddress attribute value. This array
• TaskLevelMask (INT)
The attribute of the type INT specifies the value of the interrupt
mask, which, typically, corresponds to the middle level of enabled
interrupts in the system.
• InitialMask (INT)
The attribute of the type INT specifies the value of the interrupt
mask, which, typically, corresponds to the initial level of enabled
interrupts during the system startup.
• ISRCategory1 (BOOLEAN)
The attribute specifies whether the ISR of category 1 is supported
by OS or not. Currently this attribute does not affect OS code.
N O N - D I S C L O S U R E
• ISRCategory2 (BOOLEAN)
The attribute specifies whether the ISR of category 2 is supported
by OS or not. Currently this attribute does not affect OS code.
• ISRCategory3 (BOOLEAN)
The attribute specifies whether the ISR of category 3 is supported
by OS or not.
• ISRCtxRegNum (INT)
The attribute specifies the number of extended registers to be
saved into ISR stack frame. It should contain value from 1 till 18.
Intended for MPC505 only, not implemented yet. Valid only if
ExtendedContext = TRUE.
• SaveISRCtxExt (STRING)
The attribute specifies the assembler macro for saving extended
registers into ISR stack frame. It should be a STRING which
R E Q U I R E D
contains inline assembler statements for saving extended
registers. Intended for MPC505 only, not implemented yet. Valid
only if ExtendedContext = TRUE.
• RestoreISRCtxExt (STRING)
The attribute specifies the assembler macro for restoring
extended registers from ISR stack frame. It should be a STRING
which contains inline assembler statements for restoring extended
registers. Intended for MPC505 only, not implemented yet. Valid
only if ExtendedContext = TRUE.
A G R E E M E N T
• UnorderedExceptions (BOOLEAN)
The attribute allows handling of unordered exceptions. Intended
for MPC only.
• Resources (BOOLEAN)
This attribute defines whether resource management is provided
by OS or not.
• FastResource (BOOLEAN)
The attribute can be specified by the user to increase the system
N O N - D I S C L O S U R E
performance. If it is TRUE the system will work faster. But this
attribute may be used only for debugged applications, because
errors related to incorrect access and priority are not signalled. If
this attribute is TRUE less amount of ROM and RAM is needed for
resources. But, if resource priorities have a big difference (e.g. first
resource has priority 1 and the second resource has priority 20)
this attribute does not lead to RAM saving.
• ResourceAccessCheck (BOOLEAN)
Defines whether E_OS_ACCESS error code is returned by
GetResource service or not. If it is TRUE, then error code will be
returned in EXTENDED status based on task definition in OIL-file.
If the system has STANDARD status or FastResource property
turned on or more than 8 resources (including Scheduler) are
defined in application, then this attribute should be set to FALSE.
• Events (BOOLEAN)
This attribute defines whether event management is provided by
OS or not.
• Counters (BOOLEAN)
This attribute defines whether counters are provided by OS or not.
A G R E E M E N T
• CounterSize (ENUM)
This attribute defines the size of all counters. The valid values are
8, 16 and 32 which conform to byte, word and long word size of
counters.
• Alarms (BOOLEAN)
This attribute defines whether alarms are provided by OS or not.
• AlarmList (BOOLEAN)
If the attribute is TRUE the running alarms are linked into a list
which decreases the time for alarm handling.
• AlarmDeltaList (BOOLEAN)
If the option is turned on the running alarms are linked into ordered
N O N - D I S C L O S U R E
R E Q U I R E D
• MinAlarmRAM (BOOLEAN)
If the option is turned on, the alarm handling is optimized for
memory (RAM). Otherwise, alarm handling is optimized for speed.
When turned on, the alarm control block is significantly decreased,
especially when AlarmList option is turned off.
• TimerHardware (ENUM)
This attribute is intended to select the hardware interrupt source
for the system counter (among the accessible MCU devices). See
Section 15 HC12 Platform-Specific Features and
Apppendix E Quick Reference for details about possible
A G R E E M E N T
meanings of these parameters.
• SysTimer (BOOLEAN), Prescaler (BOOLEAN), PrescalerValue
(INT), TimerModulo (BOOLEAN), TimerModuloValue (INT)
The set of parameters to tune the selected hardware interrupt
source is introduced:
SysTimer, Prescaler, PrescalerValue, TimerModulo,
TimerModuloValue. One or more parameters can be here in
accordance with the hardware features. For more details see
Section 15 HC12 Platform-Specific Features. This
parameter(s) can be omitted.
N O N - D I S C L O S U R E
13.3.6 Messages Related Attributes
• UnqueuedMessages (BOOLEAN)
The attribute allows Unqueued Messages in the system.
• UnqueuedMsgDefaultValue (BOOLEAN)
The attribute allows Unqueued Messages to have default values.
• QueuedMessages (BOOLEAN)
The attribute allows Queued Messages in the system.
• QueuedMsgOneToN (BOOLEAN)
If the attribute is TRUE, 1:N Queued Messages are allowed.
• ActivateOnMsg (BOOLEAN)
If the attribute is TRUE task activation on message arrival is
supported.
• AlarmOnMsg (BOOLEAN)
If the attribute is TRUE an alarm can be linked to message arrival.
• SetEventOnMsg (BOOLEAN)
If the attribute is TRUE event setting is allowed on message
arrival.
• ErrorHook (BOOLEAN)
If the attribute is TRUE the user’s hook for error handling is
supported by the system (the ErrorHook hook routine).
• PreTaskHook (BOOLEAN)
If the attribute is TRUE the user’s hook for context switching is
supported by the system (the PreTaskHook hook routine).
• PostTaskHook (BOOLEAN)
If the attribute is TRUE the user’s hook for context switching is
supported by the system (the PostTaskHook hook routine).
• StartupHook (BOOLEAN)
If the attribute is TRUE the user’s hook is called by the system at
N O N - D I S C L O S U R E
R E Q U I R E D
• UserCommand1 (STRING)
The attribute defines entry point of the user's hook #1 to be called
from the OS Dispatcher thread (for OS/NT with interrupt emulation
only).
• UserCommand2 (STRING)
The attribute defines entry point of the user's hook #2 to be called
from the OS Dispatcher thread (for OS/NT with interrupt emulation
only).
• UserCommand3 (STRING)
A G R E E M E N T
The attribute defines entry point of the user's hook #3 to be called
from the OS Dispatcher thread (for OS/NT with interrupt emulation
only).
N O N - D I S C L O S U R E
• Task management services:
ActivateTask, TerminateTask,ChainTask,
ChainTaskItself, Schedule, GetTaskId, GetTaskState,
GetTCBInfo
• Resource management services:
GetResource, ReleaseResource
• Event management services:
SetEvent, ClearEvent, GetEvent, WaitEvent
• ISR management services:
EnterISR, LeaveISR, EnableInterrupt, DisableInterrupt,
GetInterruptDecsriptor
• Counter related services:
InitCounter, CounterTrigger, AdvanceCounter,
GetCounterValue, GetCounterInfo
This object presents a task. Attributes of this object type define task
properties. Links with other system objects are defined via references.
The keyword TASK is used for this object type. See Section 4 Task
Management for more detailed information about OSEK tasks. The
sample of a task definition is:
N O N - D I S C L O S U R E
TASK TaskA {
TYPE = EXTENDED;
PRIORITY = 2;
SCHEDULE = NON;
ACTIVATION = 5;
STACKSIZE = 64;
AUTOSTART = TRUE;
EVENTS = { event1, event2, event3 };
};
• TYPE (ENUM)
This attribute has the type ENUM. The OSEK task may be one of
the following types:
– BASIC
R E Q U I R E D
– EXTENDED
• PRIORITY (INT)
The priority of the task is defined by the value of the PRIORITY
attribute. The bigger value of the PRIORITY attribute corresponds
to the higher priority. This attribute has the INT type. The default
value range is from 0 to 255.
• SCHEDULE (ENUM)
The run-time behavior of the task is defined by this attribute. If the
task may be preempted by another one at any point of execution
A G R E E M E N T
- this task attribute shall have the FULL value (preemptive task). If
the task can be preempted only at specific points of execution
(explicit rescheduling points) the attribute shall have the NON
value (non-preemptive task). This attribute has the type ENUM
with the values:
– FULL
– NON
• ACTIVATION (INT)
The maximum number of registered activation requests for the
task. This attribute has the INT type. The default value range is
from 1 to 255. The maximum number can be constrained in the
implementation specific definition part. The value 1 means that a
task cannot be multiple activated, only single activation is allowed.
N O N - D I S C L O S U R E
• STACKSIZE (INT)
This attribute defines the size of the task stack. It depends on the
CPU family and functionality of the task. The attribute has the type
INT. No default value range is defined. The maximum stack size
can be constrained by the implementation.
• AUTOSTART (BOOLEAN)
This attribute determines whether the task is activated during the
system start-up procedure or not. It has the BOOLEAN type, so
the possible values are TRUE and FALSE.
• StackMethod (ENUM)
This attribute specifies the stack allocation method. The attribute
(the ENUM type) has three available values. NODESTACK means
that task node stack is implicitly assigned to be used by the task
(during the task activation). POOLSTACK means that a stack
attribute is used
• PersistentNode (BOOLEAN)
If the attribute is TRUE a persistent task node is assigned to the
task.
• PersistentStack (BOOLEAN)
If the attribute is TRUE a persistent stack buffer is assigned to the
task.
R E Q U I R E D
• RESOURCE (multiple)
If the task accesses a resource at run-time this resource shall be
pointed. The resource Ceiling priority is calculated as the highest
priority of tasks accessing this resource (or higher one).
• EVENT (multiple)
An extended task can have a set of events. These events can be
cleared and waited for by the task. All task events shall be pointed
to define the event mask in case of auto-assignment (see section
Section 13.7 Event Definition).
A G R E E M E N T
• MESSAGESENT (multiple)
If a task sends a message (has write access to a message) this
message shall be specified as the reference. The symbolic name
of the message shall be pointed.
• MESSAGERECEIVED (multiple)
If a task receives a message (has read access to a message) this
message shall be specified as the reference. The symbolic name
of the message shall be pointed.
N O N - D I S C L O S U R E
• StackPool (single)
If a task uses the stack from a stack pool the reference to the
dedicated stack pool must be provided. The symbolic name of the
stack pool shall be pointed.
NOTE: If a task uses a stack from the stack pool the value of the task attribute
STACKSIZE is ignored.
This statement is used to define stack pool data. Several statements can
be in the configuration file, each statement defines one pool. The
keyword for this object is STACK. See Section 4.7.4 Task Stack for
more information about the task stack. The sample of a stack definition
is:
STACK StackTaskA {
StackSize = 128;
NumberOfStacks = 5;
StackAreaAddress = 0x400;
};
• StackSize (INT)
The attribute represents the size of a stack buffer, it has the type
INT.
• NumberOfStacks (INT)
The attribute corresponds the number of buffers in the pool, it also
has the type INT.
• StackAreaAddress (STRING)
The attribute specifies the start address of the pool memory area
and it has the type STRING. This optional parameter serves for
N O N - D I S C L O S U R E
RESOURCE ResAccess {
};
R E Q U I R E D
13.6.1 Object Attributes
• PRIORITY (INT)
The priority of the resource is defined by the value of the
PRIORITY attribute. The bigger value of the PRIORITY attribute
corresponds to the higher priority. This attribute has the INT type.
This attribute has the possibility of automatically assignment. In
this case the resource Ceiling priority is calculated automatically
on the basis of information about priorities of tasks using the
A G R E E M E N T
resource.
This object is intended for the event management. The event object has
no references. The keyword EVENT is used for this object type. Section
Section 9 Events describes events in OSEK. The sample of an event
definition is:
EVENT event1 {
MASK = 0x01;
N O N - D I S C L O S U R E
};
COUNTER Timer {
MINCYCLE = 16;
MAXALLOWEDVALUE = 128;
TICKSPERBASE = 90;
};
A G R E E M E N T
• MAXALLOWEDVALUE (INT)
The attribute defines the maximum allowed counter value. When
the counter reaches this value it rolls over and starts count again
from zero. The attribute has the type INT.
• MINCYCLE (INT)
The attribute specifies the minimum allowed number of counter
ticks for a cyclic alarm linked to the counter. (In fact, this parameter
has a sense only for systems with extended OS status since it is
N O N - D I S C L O S U R E
checked in this case only.) The attribute has the type INT.
• TICKSPERBASE (INT)
For the system timer (if specified) this is the number of ticks that
are required to reach 10 milliseconds. This value cannot be
derived automatically from other counter related attributes (see
also PrescalerValue, TimerModuloValue
Section 13.3.5 Counters and Alarms Related Attributes). For
the rest counters this attribute specifies the number of ticks
required to reach a counter-specific value (the interpretation is up
to the user). The attribute has the type INT.
• TICKDURATION (INT)
For the system timer (if specified) this is the duration of a tick in
nanoseconds. The attribute has the type INT.
R E Q U I R E D
• SystemTimer (BOOLEAN)
This attribute specifies whether the counter is the system timer. By
default this attribute has the value FALSE. Note, however, that
only one counter must be defined as the system timer.
A G R E E M E N T
Links with other system objects are defined via references. The
referenced counter and task must be already defined.The keyword
ALARM is used for this object type. See section Section 8.4 Alarms for
information about alarms. The sample of an alarm definition is:
ALARM WakeTaskA {
ACTION = SETEVENT;
COUNTER = Timer;
TASK = TaskA;
EVENT = event1;
};
N O N - D I S C L O S U R E
An alarm has the following allowed references:
• ACTION (single)
This attribute has the type ENUM. The ACTION may be one of the
following types:
– ACTIVATETASK
– SETEVENT
• COUNTER (single)
An alarm shall be assigned to a particular counter to have an
ability to operate.
• TASK (single)
The reference points to a task which is to be notified via activation
or event setting when the alarm expires.
• EVENT (single)
An event which is to be set when the alarm expires is pointed here.
The event is considered as an inseparable pair of the task and the
event belonging to this task, so the reference to the task which
owns the events shall be also defined for this alarm.
MESSAGE Msg4TaskA {
TYPE = UNQUEUEDMESSAGE;
ITEMTYPE = "int";
ITEMS = 1;
ALARMRESETTIME = 20;
ALARMRESET = DrvAlarm;
ACTION = SETEVENT;
N O N - D I S C L O S U R E
TASK = TaskA;
EVENT = event1;
};
• ACTION (ENUM)
This attribute has the type ENUM. The ACTION may be one of the
following types:
– ACTIVATETASK
– SETEVENT
– NONE
R E Q U I R E D
• TYPE (ENUM)
In accordance with the OSEK specification there are two types of
messages: Unqueued and Queued. The possible value of this
attribute are the following:
– UNQUEUEDMESSAGE
– QUEUEDMESSAGE
• ITEMTYPE (STRING)
The message item can have the own type which has to be any C
data type. Any ANSI-C type specifier is allowed. It is the standard
C type identifier - char, int, float, double with any type
A G R E E M E N T
modifiers (signed, unsigned, short, long) and also
structure or union specifier (starting struct or union), enum
specifier (starting enum), typedef name (any valid C-language
identifier) enclosed in the double quotas. To use an array of
standard C-language type the user must define the new type via
typedef operator. In case of user’s defined data types or
enumerations such definitions must be in the user’s code before
using files produced by SG
• ITEMS (INT)
The queued message can have more than one item. This attribute
specifies the capacity of the FIFO queue, i.e. the number of
message items into the FIFO queue. The unqueued message
N O N - D I S C L O S U R E
always has only one item.
• ALARMRESETTIME (INT)
Alarm can be assigned to a message which is restarted at
message arrival (alarm restart will happen as a result of
SendMessage service execution). The time period for this alarm is
defined by this attribute. The units are ticks of the counter
assigned for the alarm.
• StartupAlarm (BOOLEAN)
This attribute specifies whether the alarm referenced by the
message must be restarted during system start-up. By default this
attribute has the value FALSE, it means that the alarm is not
restarted during start-up. Restarting of the alarm may be used to
trap the loss of the first message.
• DefaultValue (STRING)
This attribute presents the address of the ROM-based variable,
which holds the default value of the unqueued message. This
variable must have the type <ITEMTYPE>, and must be located in
the user’s code. The parameter may be omitted.This attribute is
intended for unqueued messages only.
• ReceiverNum (INT)
The attribute defines the number of local task-receivers of the
message. If it has a value greater than 1, then it is assumed, that
A G R E E M E N T
• ALARMRESET (single)
The reference points to an alarm which is to be restarted when the
message arrives (alarm restart will happen as a result of
SendMessage service execution).
• TASK (single)
The reference points to a task which is to be notified via activation
or event setting when the message arrives.
• EVENT (single)
An event which is to be set when the alarm expires is pointed here.
The event is considered as an inseparable pair of the task and the
event belonging to this task, so the reference to the task which
owns the events shall be also defined for this message.
R E Q U I R E D
13.11 ISR Definition
Description:
ISR TimerISR{
CATEGORY = 2;
}
A G R E E M E N T
13.11.1 Object Attributes
• CATEGORY (ENUM)
Specifies category of the Interrupt Service Routine. Possible
values are: 1, 2 or 3 (see Section 6.4 ISR Categories for
Interrupt Service Routine Categories details).
• TYPE (ENUM)
This attribute is only valid if TargetMCU global system attribute is
MCORE and HCAltRegISR global system attribute is TRUE. It
chooses between Fast Interrupt exception and all other
N O N - D I S C L O S U R E
exceptions. The possible values of this attribute are the following:
– FAST
– NORMAL
The following is the OIL example of CPU description with two application
modes and five tasks. Task TC code is shared between application
modes.
N O N - D I S C L O S U R E
R E Q U I R E D
ALARM Alarm { ... }; /* Alarm definition */
....
};
A G R E E M E N T
N O N - D I S C L O S U R E
14.1 Contents
14.2 Application Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
A G R E E M E N T
14.3 Action Sequence to Build an Application . . . . . . . . . . . . . . . .172
14.4 Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
N O N - D I S C L O S U R E
each other.
R E Q U I R E D
Application
configuration
file User’s source
code
System
Generator
OSEK
A G R E E M E N T
Files produced by SG OS kernel
Compiler
Linker
Executable file
N O N - D I S C L O S U R E
Figure 14-1. Application building process
R E Q U I R E D
assign another name (see Section 14.3.2 Source Files).
2. The header file which contains definitions of data types and
constants, and external declarations of variables which are
needed to describe system objects. This file is used to compile
application files. By default, System Generator uses the input file
name for this output file with “.h” extension.
3. The source file which contains initialized data and memory
allocation for system objects. This file is compiled with “osprop.h”
and other header files and then linked together with other
application and OS files. By default, System Generator uses the
input file name for this output file with “c” extension.
A G R E E M E N T
NOTE: As a rule, the user is not allowed to edit files produced by the System
Generator. It may lead to data inconsistency, compilation errors or
unpredictable application behavior.
N O N - D I S C L O S U R E
The OS source code is compiled and linked together with other
application’s files. The header file “osprop.h” describing system
properties defines which functionality will have the OS kernel in run time.
This file must be included in all user’s and OS’ source files. Since the
user can specify another name for this file the special macro OSPROPH
is designed to substitute the name. The following code can be used in all
user’s files (it is used in all OS source files):
-dOSPROPH="<filename>".
But the user is allowed to use some other method to include the property
definition header file in his/her source code.
#if defined(APPTYPESH)
#include APPTYPESH /* user’s header file */
#endif /* defined(APPTYPESH) */
-dAPPTYPESH="<filename>".
N O N - D I S C L O S U R E
<filename> is the name of the file with user defined structures and
data declarations.
In the example below two variables and one data type are defined by the
user which are referenced in files generated by SG. Variables are
defined in the user’s file “user.c” and referenced in the produced file
“cfg.c”. The data type is defined in the user’s file “user.h” and referenced
in the produced file “cfg.c”. The user’s code can be the following:
USER.H file:
R E Q U I R E D
#define MYISRSTACKSIZE100
USER.C file:
A G R E E M E N T
...
...
#if defined(APPTYPESH)
#include APPTYPESH /* user’s header file */
#endif /* defined(APPTYPESH) */
...
/* SG generated code referring to user’s type and data */
...
-dAPPTYPESH="USER.H".
N O N - D I S C L O S U R E
The code of user’s tasks and functions should be developed according
to common rules of the C language. But some exceptions exist:
• The keyword TASK and ISR should be used to define a task and
ISR correspondingly;
• For objects controlled by the OSEK Operating System the data
types defined by the system must be used. The data types are
described at the end of previous sections and in
Section 17 System Services.
When all needed header and source files are created or produced by the
System Generator an application can be compiled and linked (for details
see Appendix 15 HC12 Platform-Specific Features).
15.1 Contents
15.2 Compiler-Specific Features . . . . . . . . . . . . . . . . . . . . . . . . . .179
A G R E E M E N T
15.3 Interrupt Flag Manipulation Specific Features . . . . . . . . . . . .180
15.4 HC12 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182
15.5 Task Stack Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192
N O N - D I S C L O S U R E
It is recommended to add environment variables and paths to access
compiler directories and OSEK directory. Installation procedure
suggests the user to set these variables automatically and place it into
OSEK OS Environment Configuration file (MAKE.BAT by default). If they
were not set during installation the user should do it manually.These
variables are the following:
The user should set the next compiler definitions to provide the selection
of the Cosmic platform and the selection of the board being used:
This version of the OSEK Operating System manipulates with CCR X-bit
and I-bit only (external interrupt registers are not affected), therefore it is
not possible to use OSEK services from interrupts below XIRQ.
R E Q U I R E D
HC12 OS services for interrupt flag manipulation simply disable and
enable interrupts and inquire the current status of the interrupt flags
(CCR X-bit and I-bit). If a task is preempted by other task or suspended
its interrupt mask is saved. When the task is resumed its saved interrupt
mask is restored. When a task is activated it has either the interrupt
mask specified in the task definition statement (attribute InterruptMask
in OIL-file) or the interrupt mask specified in the interrupt definition
statement (attribute TaskLevelMask in OIL-file - common mask value for
all tasks which have undefined InterruptMask attribute)
A G R E E M E N T
descriptors(logicmask).
0x10 – I-bit interrupts are enabled (CCR I-bit is cleared, X-bit is set);
0x40 – X-bit interrupts are enabled (CCR X-bit is cleared, I-bit is set);
0x50 – I-bit and X-bit interrupts are enabled (CCR I-bit and X-bit are
cleared);
0x00 – internal interrupts are disabled (CCR I-bit and X-bit are set).
N O N - D I S C L O S U R E
All other bits of CCR are not affected in OSEK system services.
However, it should be kept in mind that not all MCUs based on CPU12
core have base page available for data. For example, MC68HC812A4
uses base page for registers, and using of base page for OSEK OS
N O N - D I S C L O S U R E
should be avoided (i.e. both options described above must be turned off)
NOTE: The current OSEK Operating System for HC12 has this feature
implemented for Cosmic software only.
R E Q U I R E D
Any of these variables or both should be set in compiler options, and
memory allocation should be adjusted in linker directives. As very first
step of reset handling the INITRM register should be set equal to bits
15:11 of the _BASERAM value, and INITRG register should be set equal
to bits 15:11 of the _BASE value.
A G R E E M E N T
• baseram defines the start address of the RAM area (i.e. value
_BASERAM variable).
If basereg or baseram are set in makefile, the compiler options and linker
directives are adjusted, and initialization of INITRM and INITRG
registers is made automatically (corresponding procedure is defined in
“vector.c” file).
N O N - D I S C L O S U R E
[...]\OSEK\SAMPLE directory. This file is the example of the interrupt
vector table coding. The user should copy this file into the project
directory and there modify it as needed.
R E Q U I R E D
Address (hex)
$0000
– start-up code
Non-banked – OSEK OS code
memory – ISR
$FFFF
$08000
Bank 0
A G R E E M E N T
$0BFFF
$18000
– task code
Bank 1 – any functions called
$1BFFF from the task/ISR
– other application code
•••
$68000
Bank 6
$6BFFF
N O N - D I S C L O S U R E
15.4.3.2 Configuration of the Application for Banked Memory
More details may be found in the sample code and makefile, as well in
the compiler User’s manuals.
The compiler supports bank switching for code only, using the internal
window mechanism provided by the MC68HC12 processor, or using any
external user provided mechanism. Bank switching is supported via:
-m modf:hmodf.h
+modf
The following directive is used to locate the banked section bank1 in the
physical bank #1:
R E Q U I R E D
+seg .bank1 -b 0x18000 -p1
A G R E E M E N T
(ROM for the Operating System).
N O N - D I S C L O S U R E
is reduced. Use of different contexts (preemptive and non-preemptive)
have a sense for CPUs with many registers if some of them are not
included into the non-preemptive context.
In the table below all possible values to define these parameters are
listed.
N O N - D I S C L O S U R E
R E Q U I R E D
Table 15-1. Parameters to define System Timer hardware
PrescalerValue
TimerHardware TimerModuloValue
bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
MC68HC812A4
TIMTOI BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 N/A
TIMOC0 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
TIMOC1 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
TIMOC2 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
TIMOC3 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
A G R E E M E N T
TIMOC4 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
TIMOC5 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
TIMOC6 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
TIMOC7 BCSC BCSB BCSA MCSB MCSA PR2 PR1 PR0 0...65535
RTI BCSC BCSB BCSA MCSB MCSA RTR2 RTR1 RTR0 N/A
MC68HC912B32, MC68HC912D60, MC68HC912DA128
TIMTOI N/A N/A N/A N/A N/A PR2 PR1 PR0 N/A
TIMOC0 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
TIMOC1 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
TIMOC2 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
TIMOC3 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
N O N - D I S C L O S U R E
TIMOC4 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
TIMOC5 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
TIMOC6 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
TIMOC7 N/A N/A N/A N/A N/A PR2 PR1 PR0 0...65535
RTI N/A N/A N/A N/A N/A RTR2 RTR1 RTR0 N/A
additionally for MC68HC912D60, MC68HC912DA128
MDC N/A N/A N/A N/A N/A N/A MCPR1 MCPR0 0...65535
The bits 7:6:5 of the prescaler contain the values to be set in the base
clock select bits BCSC:BCSB:BCSA of the clock control register
CLKCTL. The bits 4:3 of the prescaler contain the values to be set in the
module clock select bits MCSB:MCSA of the clock control register
CLKCTL. The bits 2:1:0 of the prescaler contain the values to be set
either in the timer prescaler select bits PR2:PR1:PR0 of the timer
interrupt mask 2 register TMSK2 or in the base clock select bits
NOTE: MC68HC912B32 MCU does not allow the following values of prescaler
bits PR2:PR1:PR0: 1:1:0 and 1:1:1.
Thus, the system definition statements for the OSEK Operating System
A G R E E M E N T
OS <name> {
...
SysTimer = <SysTimerDefined>;
TimerHardware = <HardwareType>;
Prescaler = <PrescalerDefined>;
PrescalerValue = <HardwarePrescaler>;
TimerModulo = <ModuloDefined>;
TimerModuloValue = <HardwareModulo>;
...
};
For example, the system timer is based on the Output Compare channel
5 interrupt, with no Prescaler and Modulo Counter value equals 1024. In
this case the definition statement can be the following:
N O N - D I S C L O S U R E
OS <name> {
...
SysTimer = TRUE;
TimerHardware = TIMTOI;
Prescaler = FALSE;
...
};
OS <name> {
...
SysTimer = TRUE;
TimerHardware = RTI;
Prescaler = TRUE;
PrescalerValue = 0x01;
R E Q U I R E D
TimerModulo = FALSE;
...
};
NOTE: The system timer will not be triggered if the EntryExitISR property is
turned OFF!
A G R E E M E N T
use simplified scheduler (the property SimpleScheduler must be turned
ON). In this case all tasks running concurrently must have different
priorities.That is, two tasks may have the same priority if they are never
both in ready state and they must have different priorities otherwise. The
simple scheduler uses prioritized table of task nodes and works faster. It
requires less amount of ROM and RAM than the standard scheduler.
N O N - D I S C L O S U R E
15.4.7 Alarms Configuration
• ActivateTask - up to 4 bytes;
• CounterTrigger - up to 12 bytes;
• SetRelAlarm/SetAbsAlarm - up to 4 bytes.
16.1 Contents
16.2 System Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
A G R E E M E N T
16.3 Using OS Extended Status for Debugging . . . . . . . . . . . . . . .193
16.4 Context Switch Routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . .194
16.5 Stack Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195
16.6 Known Problems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195
In this section some advice is given which may be useful for developers
working with the OSEK Operating System.
N O N - D I S C L O S U R E
etc.). This tool processed the configuration file created by the user and
reports about inconsistencies and errors in it. Most of possible mistakes
in application configuration process can be eliminated with the help of
SG. See Section 12 System Configuration and Section 14 Building
of Application about system generation process.
additional check and this error is not indicated and the application
behavior will be unpredictable!
When all errors in an application will be eliminated you may turn off the
Extended Status and remove additional status checks from the
application to get the reliable application of the smaller size.
Example: The user can set time stamps enabling him to trace the
program execution at the following locations before calling operating
system services:
R E Q U I R E D
The user can optionally use hook routines or establish a watchdog task
that takes “one-shot displays” of the operating system status.
A G R E E M E N T
program executes at some incorrect address.
N O N - D I S C L O S U R E
Tasks should have enough stack for their execution, therefore it is
recommended to pay attention on task definition statements to provide
each task with a needed amount of stack. See Section 15 HC12
Platform-Specific Features.
17.1 Contents
17.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197
A G R E E M E N T
17.3 Task Management Services . . . . . . . . . . . . . . . . . . . . . . . . . .199
17.4 ISR Management Services . . . . . . . . . . . . . . . . . . . . . . . . . . .210
17.5 Resource Management Services . . . . . . . . . . . . . . . . . . . . . .220
17.6 Counters and Alarms Management Services . . . . . . . . . . . . .225
17.7 Event Management Services . . . . . . . . . . . . . . . . . . . . . . . . .242
17.8 Communication Management Services . . . . . . . . . . . . . . . . .249
17.9 Operating System Execution Control . . . . . . . . . . . . . . . . . . .259
17.2 General
N O N - D I S C L O S U R E
This section provides detailed description of all OSEK OS run-time
services including hook routines. Also declarations of system objects –
the constructional elements – are described here. The services are
arranged in logical groups – for the task management, the interrupt
management, etc.
Examples of code are also provided for every logical group. These
examples have no practical meaning, they only show how it is possible
to use OS calls in an application.
Declaration element:
Service description:
StatusType.
of the service.
R E Q U I R E D
...RefType: describes the identifier referencing an object1.
A G R E E M E N T
The OSEK OS establishes the following data types for the task
management:
N O N - D I S C L O S U R E
17.3.2 Constants
The following constants are used within the OSEK Operating System to
indicate task states:
17.3.3 Conventions
TASK ( TaskName )
{
...
}
The only data types must be used for operations with tasks.
Syntax:
Input:
Description:
Particularities: none
R E Q U I R E D
17.3.5 ActivateTask
Syntax:
Input:
Output:
• None.
A G R E E M E N T
Description:
Particularities:
The service may be called both on the task level (from a task) and the
interrupt level (from ISR). This service may be called also by
StartupHook hook routine.
N O N - D I S C L O S U R E
In the case “call from ISR”, the operating system will reschedule tasks
only after the ISR completion.
Status:
• Standard:
– E_OK – no error;
• Extended:
– E_OS_ID – the task identifier TaskName is
invalid;
– E_OS_LIMIT – too many task activations of the
specified task or there is no enough
resources to activate the task.
17.3.6 TerminateTask
Syntax:
Input:
• None.
A G R E E M E N T
Output:
• None.
Description:
This service causes the termination of the calling task. The calling task
is transferred from the running state into the suspended state and
releases all occupied system resources (that is, the stack, the task node,
etc.) except task has multiply activation requests.
Particularities:
The resources occupied by the task must have been released before.
N O N - D I S C L O S U R E
If the call was successful, TerminateTask does not return to the call level
and the status can not be evaluated. If the service TerminateTask is
called successfully, it enforces a rescheduling.
If the system with extended status is used, the service returns in case of
error, and provides a status which can be evaluated in the application.
Status:
• Standard:
– No return to the caller.
• Extended:
– E_OS_RESOURCE – the task still occupies resources;
R E Q U I R E D
– E_OS_CALLEVEL – a call at the interrupt level.
17.3.7 ChainTask
Syntax:
Input:
A G R E E M E N T
• <TaskName> – a reference to the sequential succeeding
task to be activated.
Output:
• None.
Description:
This service causes the termination of the calling task. After termination
of the calling task a succeeding task <TaskName> is activated
sequentially. Using this service, it ensures that the succeeding task only
starts to run after the calling task has been terminated.
N O N - D I S C L O S U R E
Particularities:
If the succeeding task is identical with the current task, this does not
result in multiple requests. In this case the task will be terminated and
after that activated again. It can be used, e.g. if multiple activation is
disabled but it is needed to restart a task. If it is not needed to have such
tricks the system property ChainTaskItself can be turned off to decrease
the task control block size.
The resources occupied by the calling task must have been released
before.
If called successfully, ChainTask does not return to the call level and the
status can not be evaluated. In this case a rescheduling is enforced.
If the version with Extended Status is used, the service returns in case
of error to the calling task, and provides a status which can be evaluated
by the application.
Status:
• Standard:
– If the service is called successfully, then no return to the caller;
A G R E E M E N T
• Extended:
– E_OS_ID – the task identifier is invalid;
– E_OS_LIMIT – too many activations of
<TaskName> or there is not enough
resources to activate the task.
– E_OS_RESOURCE – the calling task still occupies
resources;
– E_OS_CALLEVEL – a call at the interrupt level.
17.3.8 Schedule
Syntax:
Input:
• None.
Output:
• None.
Description:
If a higher-priority task is ready, the current task is put into the ready
state and a higher-priority task is executed. Otherwise the calling task is
R E Q U I R E D
continued without delay. By means of using this service the task
explicitly yields control to a higher-priority ready task (if any exists).
Particularities:
A G R E E M E N T
excluded from the OSEK OS code.
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_CALLEVEL – a call at the interrupt level.
17.3.9 GetTaskId
N O N - D I S C L O S U R E
Syntax:
Input:
• None.
Output:
Description:
This system service returns the name (<TaskName>) of the task which
is currently active.
Particularities:
This service is useful, for instance, in the case if two or more tasks
shares the same piece of code and in some point of the code the coming
actions depend on which task is executed in the moment. This service
may be called by ErrorHook, PreTaskHook and PostTaskHook hook
routines. If the name of the task can not be evaluated (no task currently
active), the value INVALID_TASK will be returned.
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_CALLEVEL – a call at the interrupt level.
17.3.10 GetTaskState
N O N - D I S C L O S U R E
Syntax:
Input:
Output:
Description:
R E Q U I R E D
Particularities:
The service may be called both on the task level (from a task) and the
interrupt level (from ISR). This service may be called by ErrorHook,
PreTaskHook and PostTaskHook hook routines.
A G R E E M E N T
If the system configuration option GetTaskState is turned off the service
is excluded from the OSEK OS code.
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the task identifier is invalid.
N O N - D I S C L O S U R E
17.3.11 GetTCBInfo
Syntax:
Input:
• None.
Output:
Description:
Particularities:
The service may be called both on the task level (from a task) and the
interrupt level (from ISR). This service may be called by ErrorHook,
PreTaskHook and PostTaskHook hook routines.
A G R E E M E N T
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_NOFUNC – no running task, nothing done.
The example below assumes three tasks TaskA, TaskB and TaskC.
These tasks use all OSEK OS task management services to coordinate
each other.
R E Q U I R E D
The following definitions can be made in the definition file (for HC08):
...
TASK TaskA {
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 3;
StackMethod = OWNSTACK;
STACKSIZE = 64;
};
TASK TaskB {
TYPE = EXTENDED;
A G R E E M E N T
SCHEDULE = FULL;
AUTOSTART = FALSE;
PRIORITY = 2;
StackMethod = POOLSTACK;
StackPool = POOL1;
};
TASK TaskC {
TYPE = EXTENDED;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 1;
StackMethod = NODESTACK;
};
...
N O N - D I S C L O S U R E
DeclareTask( TaskA )
DeclareTask( TaskB )
DeclareTask( TaskC )
TASK( TaskA )
{
TaskType task;
TaskControlBlockType tcb;
... /* any user’s code */
TASK( TaskB )
{
TaskStateType state;
EventMaskType cc = 0x4;
... /* any user’s code */
break;
case SUSPENDED: ChainTask( TaskC );
break;
}
... /* any user’s code */
}
TASK( TaskC )
{
TaskStateType stateA, stateB;
... /* any user’s code */
while( 1 )
{
GetTaskState( TaskA, &stateA );
GetTaskState( TaskB, &stateB );
N O N - D I S C L O S U R E
The OSEK OS establishes the following data types for the interrupt
management:
R E Q U I R E D
• IntDescriptorRefType – the data type to refer variables of the
IntDescriptorType data type.
17.4.2 Constants
• INITIAL_INTERRUPT_DESCRIPTOR
– constant of data type IntDescriptorType for
initial interrupt level (see
Section 11.5 Start-up Routine).
A G R E E M E N T
17.4.3 Conventions
ISR( IsrName )
{
...
}
The keyword ISR is the macro for compiler specific interrupt function
modifier, which is used to generate valid code to enter and exit ISR.
N O N - D I S C L O S U R E
DeclareISR1( IsrName )
The same name shall be used for corresponding ISR object definition
(see Section 13.11 ISR Definition).
17.4.4 EnterISR
Syntax:
Input:
1. This service is not established by OSEK OS v.2.0 Spec. This is an extension of OSEK OS.
• None.
Output:
• None.
Description:
This function is called from the begin of the interrupt service routine,
when hardware registers are pushed onto the current stack either by
hardware or by compiler generated code. This way, the context of the
running task, or ISR, or scheduler idle loop is known on the function
entry. This context is named interrupt stack frame.
If the task is interrupted, then the pointer to the interrupt stack frame is
stored in the stack pointer field of the running task. After that the top of
the ISR stack is loaded into the CPU stack pointer, and value of the
N O N - D I S C L O S U R E
If the ISR is interrupted, then the value of the system counter of nested
interrupts is advanced by one, and function returns to the caller.
Particularities:
R E Q U I R E D
See description of interrupt categories in section Section 6.4 ISR
Categories.
Status:
• Standard:
– None.
• Extended:
A G R E E M E N T
– None.
17.4.5 LeaveISR
Syntax:
Input:
• None.
N O N - D I S C L O S U R E
Output:
• None.
Description:
If the ISR was interrupted by the corresponding EnterISR, then the value
of the system counter of nested interrupts is decremented by one, and
the function returns to the caller, because the current ISR is considered
as nested one.
If the caller is the outermost ISR (task or scheduler idle loop was
interrupted), then the function calls the scheduler to update the pointer
to the running task. After this call the function loads the task stack pointer
A G R E E M E N T
into the CPU stack pointer in assumption, that task stack pointer
contains the address of valid interrupt stack frame. If there is no running
task, then functions goes directly to the scheduler idle loop. In any case
the value of the nested interrupts counter is decremented by one.
Particularities:
Status:
• Standard:
– None.
• Extended:
– None.
17.4.6 EnableInterrupt
Syntax:
R E Q U I R E D
Input:
Output:
• None.
Description:
A G R E E M E N T
several interrupts can be controlled simultaneously, this service allows
enabling of several interrupts.
Particularities:
The service may be called from an ISR and from the task level.
For HC12 this service is intended to control only the “I” bit in the
Condition Code Register.
This service should only be used with care. It destroys the contents of
CCR according to C language conventions. In case of use it is highly
recommended to know the reaction upon system behavior!
N O N - D I S C L O S U R E
GetInterruptDescriptor before.
This service is executed also in case of return of the state is not equal
E_OK.
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_NOFUNC – at least one of the interrupts was not
disabled.
17.4.7 DisableInterrupt
Syntax:
Input:
Output:
• None.
Description:
Particularities:
The service may be called from an ISR and from the task level.
N O N - D I S C L O S U R E
For HC12 this service is intended to control only the “I” bit in the
Condition Code Register.
This service should only be used with care. It destroys the contents of
CCR according to C language conventions. In case of use it is highly
recommended to know the reaction upon system behavior!
This service is executed also in case of return of the state is not equal
E_OK.
Status:
R E Q U I R E D
• Standard:
– E_OK – no error.
• Extended:
– E_OS_NOFUNC – at least one of the interrupts was not
enabled.
17.4.8 GetInterruptDescriptor
A G R E E M E N T
Syntax:
Input:
• None.
Output:
Description:
N O N - D I S C L O S U R E
Query of interrupt status and returns the current CPU interrupt mask.
Particularities:
The service may be called from an ISR and from the task level.
For HC12 this service is intended to get only the value of the “I” bit in the
Condition Code Register.
Status:
• Standard:
– E_OK – no error.
• Extended:
– None.
The following definitions can be made in the definition file (for HC08):
...
OS myOS {
...
IsrStackSize = 64;
InterruptMaskControl = TRUE;
DisableInterruptMask = 0x0;
EnableInterruptMask = 0x8;
TaskLevelMask = 0x8;
...
};
TASK TaskB {
TYPE = EXTENDED;
SCHEDULE = FULL;
PRIORITY = 2;
N O N - D I S C L O S U R E
AUTOSTART = FALSE;
StackMethod = POOLSTACK;
StackPool = POOL1;
};
TASK IndTask {
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 1;
StackMethod = OWNSTACK;
STACKSIZE = 64;
};
COUNTER Ctr1 {
MAXALLOWEDVALUE = 24;
TICKSPERBASE = 1;
};
MESSAGE Temp {
TYPE = UNQUEUEDMESSAGE;
ITEMTYPE = "char";
ITEMS = 1;
WithCopy = TRUE;
R E Q U I R E D
};
MESSAGE Wrn {
TYPE = QUEUEDMESSAGE;
ITEMTYPE = "MSGCTYPE";
ITEMS = 6;
ReceiverNum = 3;
};
ISR ISR1_handler {
CATEGORY = 1;
};
ISR ISR2_handler {
CATEGORY = 2;
};
A G R E E M E N T
ISR ISR3_handler {
CATEGORY = 3;
};
...
ISR category 1:
ISR( ISR1_handler )
{
if( CREG != 0xC0 ) CREG |= 0x40;
N O N - D I S C L O S U R E
else CREG |= 0x03;
DREG = data1;
}
ISR category 2:
TaskStateType stateB;
DeclareCounter( Ctr1 )
DeclareTask( TaskB )
DeclareISR( ISR2_handler )
...
ISR( ISR2_handler )
{
CounterTrigger( Ctr1 );
GetTaskState( TaskB, &stateB );
if( stateB == SUSPENDED ) ActivateTask( TaskB );
}
ISR category 3:
DeclareTask( IndTask )
DeclareISR( ISR3_handler )
OSMSGTemp _Temp;
OSMSGWrn _Wrn;
int temp;
ISR( ISR3_handler )
{
/* normal temperature, do nothing */
if( (temp >= LIMIT_L ) && (temp <= LIMIT_H) ) goto exit;
/* temperature is below critical value: */
if( LIMIT_L >= temp )
{ EnterISR();
SendMessage( Temp, _Temp ); /* send msg to notify */
A G R E E M E N T
goto leave;
}
/* temperature is higher critical value: */
if( (temp >= LIMIT_H) )
{ EnterISR();
SendMessage( Wrn, _Wrn ); /* send alarm message */
ActivateTask( IndTask );
leave: LeaveISR();
}
exit: ;
}
The OSEK OS establishes the following data type for the resource
management:
The only data type must be used for operations with tasks.
17.5.2 Constants
• RES_SCHEDULER – constant of data type ResourceType (see
Section 7.3.2 Scheduler as a Resource).
R E Q U I R E D
17.5.3 Resource Declaration
Syntax:
Input:
A G R E E M E N T
Description:
Particularities: none
17.5.4 GetResource
Syntax:
N O N - D I S C L O S U R E
StatusType GetResource( ResourceType <ResName> );
Input:
Output:
• None.
Description:
This call serves to enter a critical section in the code that is assigned to
the referenced resource. A critical section must always be left using
ReleaseResource.
Particularities:
allowed if the inner critical sections are executed completely within the
surrounding critical section.
Status:
N O N - D I S C L O S U R E
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the resource identifier is invalid;
– E_OS_ACCESS – the inadmissible access to
resource;
– E_OS_CALLEVEL – a call at the interrupt level is not
allowed;
– E_OS_LIMIT – too many resources are occupied in
parallel.
R E Q U I R E D
17.5.5 ReleaseResource
Syntax:
Input:
Output:
• None.
A G R E E M E N T
Description:
This call serves to leave the critical section in the code that is assigned
to the referenced resource. An ReleaseResource call is a counterpart of
an GetResource service call.
N O N - D I S C L O S U R E
processing error), the resource is released (unlinked from the list)
in this case.
Particularities:
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the resource identifier is invalid;
– E_OS_NOFUNC – an attempt to release a resource
which is not occupied;
– E_OS_CALLEVEL – a call at the interrupt level is not
allowed.
A G R E E M E N T
The following definitions can be made in the definition file (for HC08):
...
TASK TASK_A {
TYPE = EXTENDED;
SCHEDULE = FULL;
AUTOSTART = FALSE;
PRIORITY = 3;
StackMethod = POOLSTACK;
N O N - D I S C L O S U R E
StackPool = POOL1;
};
TASK TASK_B {
TYPE = BASIC;
SCHEDULE = FULL;
PRIORITY = 2;
AUTOSTART = TRUE;
RESOURCE = { SCI_res };
StackMethod = OWNSTACK;
STACKSIZE = 64;
};
TASK SCI_TASK {
TYPE = BASIC;
SCHEDULE = FULL;
PRIORITY = 1;
AUTOSTART = TRUE;
RESOURCE = { SCI_res };
StackMethod = NODESTACK;
};
RESOURCE SCI_res {
R E Q U I R E D
}
};
...
DeclareTask( SCI_TASK )
DeclareResource( SCI_res )
TASK( SCI_TASK )
{
...
GetResource( SCI_res ); /* occupy the SCI resource */
A G R E E M E N T
... /* user’s code */
ActivateTask( TASK_B );
GetResource( RES_SCHEDULER ); /* occupy the scheduler resource */
... /* user’s code */
ReleaseResource( RES_SCHEDULER ); /* release the scheduler */
ReleaseResource( SCI_res ); /* release the SCI resource */
TerminateTask();
}
N O N - D I S C L O S U R E
The following data types are established by OSEK OS to work with
counters:
All elements have the data type TickType, and the structure looks like
the following:
{
TickType maxallowedvalue;
TickType ticksperbase;
TickType mincycle;
};
• CtrInfoRefType – the data type references data
corresponding to the data type CtrInfoType
17.6.2 Constants
• OSMAXALLOWEDVALUE
– maximum possible allowed value of the
system timer in ticks (see also
Section 13.8.1 Object Attributes);
R E Q U I R E D
• OSTICKSPERBASE – number of ticks that are required to reach
10 OSTICKPERTIMEmilliseconds in the
system counter (see also
Section 13.8.1 Object Attributes);
• OSTICKDURATION – duration of a tick of the system counter in
nanoseconds ( defined automatically by
System Generator utility (SG) (see
Section 12.2 General ), through
OSTICKSPERBASE value);
A G R E E M E N T
• OSMINCYCLE – minimum allowed number of ticks for a
cyclic alarm (only for system with Extended
Status, see also Section 13.8.1 Object
Attributes).
Syntax:
N O N - D I S C L O S U R E
DeclareCounter( CtrRefType <CounterName> )
Input:
Description:
Particularities: none
Syntax:
Input:
Description:
A G R E E M E N T
Particularities: none
17.6.4 InitCounter
Syntax:
N O N - D I S C L O S U R E
Input:
Output:
• None.
Description:
Sets the initial value of the counter with the value <Ticks>. After this call
the counter will advance this initial value by one via the following call of
R E Q U I R E D
CounterTrigger. If there are running attached alarms, then their state
stays unchanged.
Particularities:
Status:
• Standard:
– E_OK – no error.
A G R E E M E N T
• Extended:
– E_OS_ID – the counter identifier is invalid;
– E_OS_VALUE – the counter initialization value
exceeds the maximum admissible
value;
– E_OS_CALLEVEL – a call at interrupt level (not
allowed).
17.6.5 CounterTrigger
N O N - D I S C L O S U R E
Syntax:
Input:
Output:
• None.
Description:
Increments the current value of the counter. If the counter reaches the
value maxallowedvalue (see Section 17.6.1 Data Types and
Identifiers), it is reset to “zero”.
If alarms are linked to the counter, the system checks whether they
expired after this tick and performs appropriate actions (task activation
and event setting).
Particularities:
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the counter identifier is invalid.
17.6.6 AdvanceCounter
Syntax:
Input:
Output:
• None.
Description:
R E Q U I R E D
Advances the current value of the counter.
If alarms are linked to the counter, the system checks whether they
expired during specified number of ticks and performs appropriate
actions (task activation and event setting).
Particularities:
A G R E E M E N T
This service is not implemented if the system configuration option
Counters or AdvanceCounter are turned off in the configuration file.
Status:
• Standard:
– E_OK – no error;
– E_OS_VALUE – specified value is greater than
maxallowedvalue.
• Extended:
– E_OS_ID – the counter identifier is invalid.
– E_OS_CALLEVEL – call at interrupt level is invalid.
N O N - D I S C L O S U R E
Conformance: BCC1, BCC2, ECC1, ECC2
17.6.7 GetCounterValue
Syntax:
Input:
Output:
Description:
Particularities:
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the counter identifier is invalid;
– E_OS_CALLEVEL – a call at interrupt level (not allowed).
17.6.8 GetCounterInfo
N O N - D I S C L O S U R E
Syntax:
Input:
Output:
Description:
R E Q U I R E D
The return value <Info> is a structure in which the information of data
type CtrInfoType is stored.
Particularities:
Status:
A G R E E M E N T
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the counter identifier is invalid;
– E_OS_CALLEVEL – a call at interrupt level (not
allowed).
17.6.9 SetRelAlarm
N O N - D I S C L O S U R E
Syntax:
Input:
Output:
• None.
Description:
immediately after expiry with the relative value <Cycle>. Otherwise, the
alarm triggers only once.
Particularities:
Status:
• Standard:
– E_OK – no error;
– E_OS_STATE – the alarm is already in use.
• Extended:
– E_OS_ID – the alarm identifier is invalid;
– E_OS_VALUE – the alarm initialization value or cycle
value is greater than the maximum
allowed value of the counter, or the
cycle value is less than the minimum
cycle value of the counter.
Conformance:
R E Q U I R E D
• BCC1, BCC2;
• Events: ECC1, ECC2.
17.6.10 SetAbsAlarm
Syntax:
A G R E E M E N T
Input:
Output:
None.
Description:
N O N - D I S C L O S U R E
The system service occupies the alarm <AlarmName> element. The
counter will count <Start> ticks starting from zero counter value. When
<Start> ticks are reached, the task assigned to the alarm <AlarmName>
is activated or the assigned event (only for Extended Tasks) is set.
Particularities:
Since the current counter value at the moment of the service call is most
likely not equal zero, there exist the some period of time while the
counter reaches its maximum allowed value and will be logged on again
(its value will become 0). Only starting from zero <Start> ticks will be
counted.
If the absolute value <Start> is very close to the current counter value,
the alarm may immediately expire, and the task may become ready.
(E.g., the current counter value at the moment of service call equals 253,
the maximum allowed counter value equals 255 and the <Start> value is
2.)
Status:
• Standard:
– E_OK – no error;
– E_OS_STATE – the alarm is already in use.
• Extended:
– E_OS_ID – the alarm identifier is invalid;
– E_OS_VALUE – the alarm initialization value or cycle
value is greater than the maximum
N O N - D I S C L O S U R E
Conformance:
• BCC1, BCC2;
• Events: ECC1, ECC2.
17.6.11 CancelAlarm
Syntax:
Input:
R E Q U I R E D
• <AlarmName> – a reference to the Alarm.
Output:
None.
Description:
The service cancels the alarm (transfers it into the stop state).
Particularities:
A G R E E M E N T
This service is not implemented if the system configuration option
Alarms or CancelAlarm are turned off in the configuration file.
Status:
• Standard:
– E_OK – no error;
– E_OS_NOFUNC – the alarm is not in use.
• Extended:
– E_OS_ID – the alarm identifier is invalid.
N O N - D I S C L O S U R E
17.6.12 GetAlarmBase
Syntax:
Input:
Output:
Description:
Returns the alarm base characteristics into the <Info> structure. The
return value <Info> is a structure in which the information of data type
AlarmBaseType is stored.
Particularities:
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the alarm identifier is invalid.
17.6.13 GetAlarm
Syntax:
N O N - D I S C L O S U R E
Input:
Output
Description:
This service calculates the time in ticks before the alarm expires. If the
alarm is not started the E_OS_NOFUNC error code is generated.
R E Q U I R E D
Particularities:
Status:
A G R E E M E N T
• Standard:
– E_OK – no error;
– E_OS_NOFUNC – the alarm is not in use.
• Extended:
– E_OS_ID – the alarm identifier is invalid.
N O N - D I S C L O S U R E
The following definitions are made in the definition file (for HC08):
...
TASK TaskTime {
TYPE = EXTENDED;
SCHEDULE = FULL;
AUTOSTART = FALSE;
PRIORITY = 3;
StackMethod = POOLSTACK;
StackPool = POOL1;
};
TASK TASK_B {
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 2;
StackMethod = OWNSTACK;
STACKSIZE = 64;
};
TASK TASK_X {
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 1;
StackMethod = NODESTACK;
};
COUNTER TimeCnt {
MAXALLOWEDVALUE = 127;
TICKSPERBASE = 1;
};
COUNTER DgrCnt {
MAXALLOWEDVALUE = 36;
TICKSPERBASE = 1;
};
A G R E E M E N T
ALARM TimeAlm {
ACTION = ACTIVATETASK;
COUNTER = TimeCnt;
TASK = TASK_X;
};
ALARM DgrAlm {
ACTION = SETEVENT;
COUNTER = DgrCnt;
TASK = TASK_B;
EVENT = DgrAlmEvent;
};
EVENT DgrAlmEvent {
MASK = 0x01;
};
MESSAGE Norm {
TYPE = QUEUEDMESSAGE;
N O N - D I S C L O S U R E
ITEMTYPE = "int";
ITEMS = 6;
ReceiverNum = 3;
};
...
The alarm TimeAlm activates the task TASK_X when the counter
TimeCnt expires. The alarm DgrAlm sets the specified event for the
task TASK_B when the counter DgrCnt expires.
DeclareTask( TASK_B )
DeclareTask( TaskTime )
DeclareTask( TASK_X )
DeclareCounter( TimeCnt )
DeclareCounter( DgrCnt )
DeclareAlarm( TimeAlm )
DeclareAlarm( DgrAlm )
OSMSGNorm _Norm;
R E Q U I R E D
TASK( TaskTime )
{
TickType curTime;
TickType ticksToExpire;
OSBYTE i=0;
while (i != 1) {
GetCounterValue( TimeCnt, &curTime ); /* read TimeCnt value */
if( curTime == CONST )
A G R E E M E N T
{ /* if desired value, activate TaskB */
ActivateTask( TASK_B );
SetRelAlarm( TimeAlm, 10, 0 );
/* activate TaskX when TimeCnt reaches 10 */
GetAlarm( TimeAlm, &ticksToExpire );
/* just for example: TimeAlm will
expire after ‘ticksToExpire’ ticks of TimeCnt */
}
if( curTime > CONST )TerminateTask();
/* if more than desired value, terminate the task */
}
}
TASK( Task_B )
{
OSMSGNorm _Norm;
EventMaskType evMask;
N O N - D I S C L O S U R E
evMask = 0x01;
InitCounter( DgrCnt, 0 ); /* init degree counter with 0 value */
SetAbsAlarm( DgrAlm, 75, 15 ); /* set cyclic alarm */
WaitEvent( evMask );
/* wait for event which must be set by the alarm */
_Norm = 1; /* wake up and send the message that all is OK */
SendMesssage( Norm, _Norm);
TerminateTask();
}
ISR( Timer_Isr )
{
... /* reset the hardware */
EnterISR();
CounterTrigger( TimeCnt ); /* increment the counter */
LeaveISR();
}
ISR( Dgr_Isr )
{
The OSEK Operating System establishes the following data types for the
event management:
The only data types must be used for operations with events.
Syntax:
Input:
Description:
Particularities: none
R E Q U I R E D
17.7.3 SetEvent
Syntax:
Input:
A G R E E M E N T
Output:
• None
Description:
This service is used to set one or several events of the desired task
according to the event mask. If the task was waiting for at least one of
the specified events, then it is transferred into the ready state. The
events not specified by the mask remain unchanged. Only an extended
task may be referenced to set an event.
Particularities:
N O N - D I S C L O S U R E
It is possible to set events for the running task (task-caller).
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the task identifier is invalid;
– E_OS_ACCESS – the referenced task is not an
Extended Task;
– E_OS_STATE – the referenced task is in the
suspended state;
17.7.4 ClearEvent
Syntax:
Input:
Output:
• None.
Description:
The task which calls this service defines the event which has to be
cleared.
Particularities:
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ACCESS – the calling task is not an Extended
Task;
– E_OS_CALLEVEL – a call at the interrupt level is not
allowed.
R E Q U I R E D
17.7.5 GetEvent
Syntax:
Input:
Output:
A G R E E M E N T
• <Event> – a pointer to the event mask to be filled.
Description:
The event mask which is referenced to in the call is filled according to the
current state of the events of the desired task.
Particularities:
N O N - D I S C L O S U R E
Status:
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ID – the task identifier is invalid;
– E_OS_ACCESS – the referenced task is not an
Extended Task;
– E_OS_STATE – the referenced task is in the
suspended state;
17.7.6 WaitEvent
Syntax:
Input:
Output:
A G R E E M E N T
• None.
Description:
The calling task is transferred into the waiting state until at least one of
the events specified by the mask is set.
Particularities:
Status:
N O N - D I S C L O S U R E
• Standard:
– E_OK – no error.
• Extended:
– E_OS_ACCESS – the calling task is not an Extended
Task;
– E_OS_RESOURCE – the calling task occupies resources;
– E_OS_CALLEVEL – a call at the interrupt level is not
allowed.
R E Q U I R E D
17.7.7 Examples of Using Events
The example below shows how events can be used in the OSEK
Operating System.
The following definitions can be made in the definition file (for HC08):
...
TASK TASK_A {
TYPE = EXTENDED;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 3;
A G R E E M E N T
StackMethod = OWNSTACK;
STACKSIZE = 64;
};
TASK TASK_B {
TYPE = EXTENDED;
SCHEDULE = FULL;
AUTOSTART = FALSE;
PRIORITY = 3;
StackMethod = POOLSTACK;
StackPool = POOL1;
};
TASK TASK_C {
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 1;
N O N - D I S C L O S U R E
StackMethod = NODESTACK;
};
COUNTER DgrCnt {
MAXALLOWEDVALUE = 150;
TICKSPERBASE = 1;
};
ALARM AWAKE {
ACTION = SETEVENT;
COUNTER = DgrCnt;
TASK = TASK_B;
EVENT = DgrAlmEvent;
};
EVENT DgrAlmEvent {
MASK = 0x01;
};
MESSAGE Norm {
TYPE = QUEUEDMESSAGE;
ITEMTYPE = "int";
ITEMS = 6;
ReceiverNum = 3;
};
...
DeclareTask( TASK_B )
DeclareTask( TASK_C ) /* the basic task */
...
/* Check the variable and set internal flag if needed */
if (speed == LIMIT)
{
x = X_FLG;
SetEvent( TASK_A, x );
}
N O N - D I S C L O S U R E
...
R E Q U I R E D
TASK( TASK_B ) /* Extended task TASK_B */
{
EventMaskType b_ev, a_ev;
b_ev = EVMASK1 | EVMASK3;
InitCounter( DgrCnt, 10 ); /* initialize the counter */
...
SetRelAlarm( AWAKE, 20, 0 ); /* this alarm will awake the task */
WaitEvent( b_ev ); /* waiting for one of two events */
/* The task will be ready again when one of two events are set. One of
them - EVMASK1 will be set by the alarm AWAKE after 20 ticks of the counter
DgrCnt. Thus, the task can delay itself. */
A G R E E M E N T
ClearEvent( b_ev ); /* clear all events */
GetEvent( TASK_A, &a_ev ); /* get events of TASK_A */
if ( (a_ev & EVMASK2) == 0)
{
a_ev = EVMASK2;
SetEvent( TASK_A, a_ev );
} /* set the event for TASK_A */
...
}
N O N - D I S C L O S U R E
...
}
The following names are used in the OSEK Operating System for work
with messages:
17.8.2 SendMessage
Syntax:
Input:
Output:
• None.
R E Q U I R E D
Description:
In case of WithCopy:
This service updates the message object <Message> with the Data
given by <Data> and requests the transmission of the message object to
the receiving entities. The message object is locked during this update
and during the transmission of the data to the underlying communication
layer. The message object is not updated if it is already locked. This
service updates also the status information of the message object
accordingly.
A G R E E M E N T
In case of WithoutCopy:
– Possible for unqueued message type only –
This service requests the transmission of the already updated message
object to the receiving entities via the bus.
Particularities:
SendMessage does not verify whether the message object has been
initialized prior to sending it.
Status:
• Standard:
WithCopy
N O N - D I S C L O S U R E
– E_OK – message object updated,
– E_COM_LOCKED – message object locked.
WithoutCopy
– E_OK – successful operation,
– E_COM_LOCKED – message object locked.
• Extended:
– E_COM_ID – invalid parameter <Message>.
Conformance: N/A
17.8.3 ReceiveMessage
Syntax:
Input:
Output:
A G R E E M E N T
Description:
In case of WithCopy:
This service delivers the message data associated with the message
object <Message> to the applications message copy referenced by
<Data>. The message object is locked during data reception. This
service also updates the status information of the message object
accordingly.
In case of WithoutCopy:
– Possible for unqueued message type only –
N O N - D I S C L O S U R E
Particularities:
Queued messages:
R E Q U I R E D
Status:
• Standard:
WithCopy:
– E_OK – message available,
– E_COM_LOCKED – message object locked,
– E_COM_NOMSG – in case of unqueued message, no
message received so far,
– E_COM_NOMSG – in case of queued message, no
message available (FIFO empty),
A G R E E M E N T
– E_COM_LIMIT – at least one message has been lost
for a message object.
WithoutCopy:
– E_OK – successful operation,
– E_COM_LOCKED – message object locked.
• Extended:
– E_COM_ID– invalid parameter <Message>.
Conformance: N/A
17.8.4 GetMessageResource
N O N - D I S C L O S U R E
Syntax:
Input:
Output:
• None.
Description:
Particularities:
appear within the same function on the same function level. Before
terminating the task or entering the wait or suspend state the
corresponding service ReleaseMessageResource has to be used.
Status:
• Standard:
– E_OK – message object is set busy ,
– E_COM_BUSY – message object is already busy.
• Extended:
– E_COM_ID – invalid parameter <Message>.
Conformance: N/A
N O N - D I S C L O S U R E
17.8.5 ReleaseMessageResource
Syntax:
Input:
Output:
• None.
R E Q U I R E D
Description:
Particularities:
A G R E E M E N T
application in case without copy configuration.
Status:
• Standard:
– E_OK – message object unlocked
successfully.
• Extended:
– E_COM_ID – invalid parameter <Message>.
N O N - D I S C L O S U R E
Conformance: N/A
17.8.6 GetMessageStatus
Syntax:
Input:
Output:
• None.
Description:
Particularities:
None.
A G R E E M E N T
Status:
• Standard:
– E_OK – no error,
– E_COM_BUSY – message object is currently in use
by the application,
– E_COM_LOCKED – message object locked irrespective
of whether the message object is
currently in use by the application
(busy),
– E_COM_NOMSG – in case of unqueued message, no
message received so far,
– E_COM_NOMSG – in case of queued message, no
N O N - D I S C L O S U R E
message available,
– E_COM_LIMIT – at least one message has been lost,
– implementation specific status information or error codes.
• Extended:
– E_COM_ID – invalid parameter <Message>.
Conformance: N/A
The following definitions can be made in the definition file (for HC08):
R E Q U I R E D
...
TASK TASK_A {
TYPE = EXTENDED;
SCHEDULE = FULL;
AUTOSTART = FALSE;
PRIORITY = 3;
StackMethod = POOLSTACK;
StackPool = POOL1;
};
TASK TASK_B {
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
A G R E E M E N T
PRIORITY = 2;
EntryPoint = "task_b";
StackMethod = OWNSTACK;
STACKSIZE = 64;
};
TASK TASK_X {
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
PRIORITY = 1;
StackMethod = NODESTACK;
};
COUNTER Post {
MAXALLOWEDVALUE = 24;
TICKSPERBASE = 1;
};
N O N - D I S C L O S U R E
MESSAGE msgAAst {
TYPE = UNQUEUEDMESSAGE;
ITEMTYPE = "int";
ITEMS = 1;
WithCopy = FALSE;
};
MESSAGE msgBAst {
TYPE = UNQUEUEDMESSAGE;
ITEMTYPE = "MSGTS";
ITEMS = 1;
WithCopy = TRUE;
};
MESSAGE msgCBst {
TYPE = UNQUEUEDMESSAGE;
ITEMTYPE = "int";
ITEMS = 1;
WithCopy = TRUE;
};
MESSAGE msgDBev {
TYPE = QUEUEDMESSAGE;
ITEMTYPE = "int";
ITEMS = 6;
ReceiverNum = 3;
};
...
DeclareTask( TASK_A )
DeclareTask( TASK_B )
DeclareTask( TASK_X )
OSMSGmsgCBst _msgCBst;
OSMSGmsgDBev _msgDBev;
DeclareCounter( Post )
TASK( TASK_A )
{
...
ReceiveMessage( msgCBst, _msgCBst ); /* get the message */
if( msgCBst == 2 ) *_msgAAst = 1;
else *_msgAAst = 33;
SendMessage( msgAAst, _msgAAst );
...
_msgBAst.x = 60;
GetCounterValue( Post, &(_msgBAst.ts) );
SendMessage( msgBAst, _msgBAst );
...
Func();
...
}
TASK( TASK_B )
R E Q U I R E D
{
TickType cur_time;
...
_msgCBst = 15;
SendMessage( msgCBst, _msgCBst );
...
ReceiveMessage( msgAAst, _msgAAst );
if( *_msgAAst == 1 ) ActivateTask( TASK_X );
A G R E E M E N T
...
The OSEK OS establishes the following data type for operation mode
representation:
N O N - D I S C L O S U R E
• AppModeType This data type represents the operating
mode.
17.9.2 GetActiveApplicationMode
Syntax:
Description:
This service returns the current application mode. It may be used to write
mode dependent code (see Section 11.6 Application Modes).
Particularities:
17.9.3 StartOS
Syntax:
Input:
A G R E E M E N T
Output:
• None.
Description:
The user can call this system service to start the system in a specific
mode. This service calls user hook StartupHook. Each application mode
consists of own set of tasks (see Section 11.6 Application Modes).
Particularities:
N O N - D I S C L O S U R E
17.9.4 ShutdownOS
Syntax:
Input:
Output:
• None.
R E Q U I R E D
Description:
The user can call this system service to abort the overall system (e.g.
emergency off). The operating system also calls this function internally,
if it has reached an undefined state and is no longer ready to run. This
service calls user hook ShutdownHook. If ShutdownHook returns, the
operating system jumps to the next statement following the initial call to
StartOS (see Section 11.7 System Shutdown).
Particularities:
A G R E E M E N T
ShutdownOS never returns to the location where it was called.
After the return from ShutdownOS service all interrupts will be disabled.
N O N - D I S C L O S U R E
17.9.5 Examples of Application Modes Usage
The following definitions can be made in the definition file (for HC08):
SCHEDULE = FULL;
AUTOSTART = TRUE;
StackMethod = OWNSTACK;
STACKSIZE = 60;
PRIORITY = 3;
};
TASK TA1 { /* ModeA specific task TA1 */
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
StackMethod = POOLSTACK;
StackPool = POOL;
PRIORITY = 2;
A G R E E M E N T
};
... /* Other ModeA tasks */
};
CFG ModeB { /* Application mode “ModeB” */
TASK TB1 { /* ModeB specific task TB1 */
TYPE = BASIC;
SCHEDULE = FULL;
AUTOSTART = TRUE;
StackMethod = POOLSTACK;
StackPool = POOL;
PRIORITY = 4;
};
TASK TC { /* Common task for both modes */
TYPE = EXTENDED;
SCHEDULE = FULL;
AUTOSTART = TRUE;
StackMethod = OWNSTACK;
N O N - D I S C L O S U R E
STACKSIZE = 60;
PRIORITY = 5;
};
... /* Other ModeB tasks */
};
STACK POOL { /* Stack pool definition */
StackSize = 60;
NumberOfStacks = 3;
}
COUNTER Timer { ... };/* Counter definition */
ALARM TimeLimit { /* Alarm definition */
ACTION = SETEVENT;
COUNTER = Timer;
TASK = TC; /* Activates common task */
EVENT = SHUTDOWN;
}
EVENT SHUTDOWN { MASK = 0x01; };
EVENT STARTTA1 { MASK = 0x02; };
EVENT STARTTB1 { MASK = 0x04; };
....
};
R E Q U I R E D
The C-language code can be the following:
A G R E E M E N T
{
NewMode = ModeA; /* Set initial application mode */
for( ; ; )
{
... /* Perform some actions before startup*/
/* and start OS in specific mode */
StartOS( NewMode );
... /* Perform some actions after system*/
/* shutdown */
}
}
N O N - D I S C L O S U R E
for( ; ; )
{
ClearEvent( SHUTDOWN|STARTTA1|STARTTB1 );
WaitEvent( SHUTDOWN|STARTTA1|STARTTB1 );
GetEvent( TC, &tc_ev );
if( ( tc_ev & SHUTDOWN ) != 0 )
{ /* Force system shutdown */
ShutdownOS( E_OK );
}
if( ( tc_ev & STARTTA1 ) != 0 )
{ /* Activate ModeA specific task */
ActivateTask( TA1 );
}
if( ( tc_ev & STARTTB1 ) != 0 )
{ /* Activate ModeB specific task */
ActivateTask( TB1 );
}
}
}
/* USer’s shutdown hook */
void ShutdownHook( StatusType Error )
{
/* Check current application mode */
if( GetActiveApplicationMode( ) = ModeA )
NewMode = ModeB; /* Next time the system will start */
/* in application mode ModeB */
else
NewMode = ModeA; /* Next time the system will start */
/* in application mode ModeA */
}
17.9.6.1 ErrorHook
Syntax:
N O N - D I S C L O S U R E
Input:
Output:
• None.
Description:
R E Q U I R E D
Particularities:
Status:
• None.
A G R E E M E N T
Conformance: BCC1, BCC2, ECC1, ECC2
17.9.6.2 PreTaskHook
Syntax:
Input:
• None.
Output:
• None.
N O N - D I S C L O S U R E
Description:
This hook is called before the operating system enters the context of the
task. This hook is called from the scheduler when it passes control to the
given task. It may be used by the application to trace the sequences and
timing of tasks’ execution.
Particularities:
Status:
None.
17.9.6.3 PostTaskHook
Syntax:
Input:
A G R E E M E N T
• None.
Output:
• None.
Description:
This hook is called after the operating system leaves the context of the
task. This hook is called from the scheduler when it switches from the
current task to another. It may be used by the application to trace the
sequences and timing of tasks’ execution.
Particularities:
N O N - D I S C L O S U R E
Status:
None.
17.9.6.4 IdleLoopHook
Syntax:
R E Q U I R E D
Input:
• None.
Output:
• None.
Description:
This hook is called by the operating system from scheduler idle loop. It
is not possible to call OSEK OS directives from this hook. Hardware
A G R E E M E N T
dependent code like manipulation with COP registers may be placed
here.
Particularities:
17.9.6.5 StartupHook
N O N - D I S C L O S U R E
Syntax:
Input:
• None.
Output:
• None.
Description:
This hook is called by the operating system at the end of the operating
system initialization and before the scheduler is running. At this point in
time the application can start tasks, alarms, initialize device drivers etc.
Particularities:
Status:
None.
A G R E E M E N T
17.9.6.6 ShutdownHook
Syntax:
Input:
Output:
• None.
N O N - D I S C L O S U R E
Description:
Particularities:
Status:
None.
18.1 Contents
18.2 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269
A G R E E M E N T
18.3 ORTI Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271
18.5 ORTI Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .275
18.2 General
The purpose of OSEK Run Time Interface (ORTI) implementation is
giving the user extended opportunities in debugging embedded OSEK
applications. The ORTI shall be supported from both sides: an OSEK OS
and a debugger. The debugger able to display information in terms of
OSEK system objects is “OSEK aware” debugger. The internal OS data
is to be made available to the debugger. For this purpose special ORTI
file is generated at configuration time by an ORTI generator. As a result,
N O N - D I S C L O S U R E
more services will be available to the user during application debugging
session.
The ORTI generator (OrtiGen) is the command line utility which uses OIL
file (App.oil) as input file. The OrtiGen utility generates static information
in the ORTI format. This utility analyzes the application configuration and
generates ORTI file. The same OIL file is processed by the SysGen and
all files with configuration data for OS are generated. After application is
compiled and linked and executable and map files are created then they
are loaded by the debugger. If the debugger is OSEK aware then it can
load also the ORTI file for this application. The information from ORTI file
provide the debugger with possibility to display information about system
objects of current implementation of OSEK OS. This process is depicted
on Figure 18-1.
OS
SysGen OrtiGen
A G R E E M E N T
Application
Configuration
Files
Compiler/Linker
OSEK Aware
Debugger
R E Q U I R E D
18.3 ORTI Features
ORTI provides two kinds of interfaces to OSEK OS data:
A G R E E M E N T
requested data in accomplished form that is not requiring additional
processing.
There are two trace ORTI interfaces: running task identification in run-
time and OSEK OS system calls identification in run-time.
The special attributes are generated for the OS object in ORTI file to
support trace interfaces. There are RUNNINGTASK and
CURRENTSERVICE attributes1.
• RUNNINGTASK
N O N - D I S C L O S U R E
This attribute specifies the name of the currently running task
within the OS.
The RUNNINGTASK attribute value presents the address of a
byte which contains either byte numeric identifier of a task which
is currently in the running state or the special byte value in case of
none tasks are in the running state. The certain values of task
identifiers are statically determined and enumerated in the type
field of RUNNINGTASK attribute of an OS object as well as the
special value (NO_TASK) representing none of tasks running.
1. These attributes are specified in the document “ORTI: OSEK Run Time Interface, Version 2.0
(Draft a), 18 February 1999”.
R E Q U I R E D
Traced Value Description
...
A G R E E M E N T
SERVICE_4_ID entering nested Service 4 call (possibly hook
routine)
SERVICE_3_ID leaving Service 4 and resuming Service 3
NO_SERVICE leaving Service 3 (possibly due to task switching)
...
N O N - D I S C L O S U R E
18.3.2 ORTI Breakpoint Interface
Information needed to display the current task status is available for the
debugger whenever the debugger is stopped (i.e. this information is not
required in real-time and hence can be read from the TCB or similar
structure).
• priority,
• current stack.
The task priority value is provided with taking into account possible task
priority changes due to a dynamic resource allocation.
A G R E E M E N T
The task state indicates a standard OSEK state the task is currently in.
• size,
• start address.
NOTE: To provide system with information about application main stack area
make sure 2 variables are defined in Cosmic link command file: __stack
(required for Cosmic start-up code) and __stackstart (should be
allocated at the lowest address byte of application main stack area). In
N O N - D I S C L O S U R E
this case Cosmic link command file may look like the following:
...
+seg .bss -a data # BSS starts after .data
+def __stackstart=@.bss # pointer to stack start value
+spc .bss=0x3F # reserve 0x3f bytes for stack in BSS
+def __stack=@.bss # stack pointer value
...
R E Q U I R E D
• DEBUG_LEVEL (ENUM)
Specifies the ORTI support in OS. The attribute can have values
0 or 1. If the system has the DEBUG_LEVEL = 0 the static ORTI
support is switched off. If the system has the DEBUG_LEVEL = 1
this mode is considered to be a debugging mode.
• ORTIRunningTask (BOOLEAN)
Specifies that the running task identification in run-time support
will be used. This attribute will be ignored if DEBUG_LEVEL = 0.
• ORTICurrentService (BOOLEAN)
A G R E E M E N T
Specifies that the OSEK OS system calls identification in run-time
support will be used. This attribute will be ignored if
DEBUG_LEVEL = 0.
N O N - D I S C L O S U R E
The OrtiGen utility has the following format of command line:
All options are case sensitive. The space between option and argument
is optional.
-n
be written. By default the first CPU in the file is used
The argument of this option defines the name of template file for the ORTI
-t
file generation
The location of the ORTI template file can be pointed either in command
line or via the ORTI_TEMPLATE environment variable.
If the ORTI generator finds an error in the source files, it either halts
processing or outputs a warning message depending on the error
severity. If there are no error, the OrtiGen returns 0, if there are mild
N O N - D I S C L O S U R E
errors the OrtiGen sends warning messages and returns 0, but does not
terminate processing, if severe errors are detected – the OrtiGen returns
2 and does not produce output file.
The ORTI generator performs the same verification as the SysGen does
and has the same format of error messages. All System Generator error
and warning messages and their formats are described in
Appendix D System Generation Error Messages.
R E Q U I R E D
W0011: DEBUG_LEVEL is not defined in implementation
A G R E E M E N T
N O N - D I S C L O S U R E
A.1 Contents
A.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279
A G R E E M E N T
A.3 Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280
A.2 Description
The Sample application delivered with the OSEK Operating System
should help to learn how to use OSEK OS. The Sample’s source files are
located in the SAMPLE directory - it contains all files needed to create
an executable file.
The Sample is not a real application and it does not perform any useful
work. But it has a certain algorithm so it is possible to track the execution.
It uses most of OSEK OS mechanisms and allows the user to have the
first look inside the OSEK OS.
N O N - D I S C L O S U R E
The Sample consists of four tasks. It uses two counters (one of them is
the standard OSEK OS timer), three alarms, one resource, one
unqueued and one queued message. Timer interrupt is handled by the
ISR.
Generally, Sample tasks are divided into two pairs. TASKSND and
TASKRCV compose the first pair and TASKPROD, TASKCONS are the
second pair. This two pairs interacts with the help of the event
mechanism.
TASKRCV receives the message MsgA and analyzes it. If the ‘value’ is
greater than the certain limit, the second part of MsgA is increased and
the event is set for the task TASKPROD (producer). In the end the task
releases the resource and terminates itself.
The task TASKPROD is activated by the StartOS routine. Just after the
activation the task activates the system counter (timer) and the counter
A G R E E M E N T
The user can watch the “normal” and “period” variables, the message
contents and so on.
R E Q U I R E D
• “cfg20.oil” – OSEK Implementation Language file (Version 2.0),
• “makefile” – command files to build the executable file,
• “vector.c”– Vector table,
• “crts.s” – Start-up module for Cosmic
• “make.bat“ – Environment Configuration file for OSEK OS (builds
executable file)
To build the executable file the user should make sure that OSEK OS
components are properly installed on the disk and pathes for the OSEK
A G R E E M E N T
directory and compiler software are known. The makefile was written for
Microsoft Visual C++ 4.2 NMAKE utility. Run the MAKE.BAT to build the
executable file. To build sample application for Cosmic compiler run
MAKE.BAT with 'c' variable set to 'cosmic12':
>MAKE "c=cosmic12"
>MAKE "type=B32"
N O N - D I S C L O S U R E
>MAKE "type=D60"
>MAKE clean
When all produced filed are ready, the executable file can be load into
the Evaluation board (HC12D60EVB for example) and run.
B.1 Contents
B.2 General Notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283
A G R E E M E N T
B.2 General Notes
The following notation is used to define four main states for run-time
services:
N O N - D I S C L O S U R E
the ready state (from waiting or suspended states). This task has
the same or lower priority than the task calling the service, or
preemption is disabled, therefore task switching will not take
place.
• Task Waiting and Context Switching (TWCS) – The service called
transfer another task into the running state (from ready, waiting or
suspended states). This task has the higher priority than the
calling task, therefore task switching is performed.
Results in Table B-1 and Table B-2 below was got on the basis of the
certain OS configuration. The list of systetm properties is shown below,
and this configuration is called in the table as “Initial”. Properties that are
not listed have their default values. In the column “Condition” the
differences from the given list (“Initial“) are indicated. For each
configuration the corresponded numbers are provided in the table.
OIL_VERSION = "2.0";
#include "mot20.oil"
CPU cpu1 {
OS os1 {
OSVERSION = 2;
TargetMCU = HC12;
CC = BCC2;
EntryExitISR = TRUE;
InterruptMaskControl = TRUE;
SCHEDULE = FULL;
TaskIndexMethod = FALSE;
StackPool = FALSE;
A G R E E M E N T
TaskOwnStack = TRUE;
PersistentNode = TRUE;
PersistentStack = FALSE;
STATUS = EXTENDED;
ErrorHook = TRUE;
StartupHook = TRUE;
ShutdownHook = TRUE;
PreTaskHook = FALSE;
PostTaskHook = FALSE;
InternalErrorHandler = TRUE;
Resources = FALSE;
FastResource = FALSE;
Events = FALSE;
Counters = TRUE;
CounterSize = 32;
Alarms = TRUE;
AlarmList = TRUE;
N O N - D I S C L O S U R E
UnqueuedMessages = TRUE;
UnqueuedMsgDefaultValue = TRUE;
QueuedMessages = FALSE;
QueuedMsgOneToN = FALSE;
ActivateOnMsg = FALSE;
AlarmOnMsg = FALSE;
SetEventOnMsg = FALSE;
DisableInterruptMask = 0x50;
EnableInterruptMask = 0x40;
TaskLevelMask = 0x40;
IsrStackSize = 255;
NodeNumber = 5;
MaxPrio = 5;
SchedStackSize = 255;
NodeStackSize = 255;
NodeStack = FALSE;
MultiplyActivation = TRUE;
};
R E Q U I R E D
All numbers in the table are the number of CPU cycles counted by
reading the free running counter. Therefore, to calculate these numbers
in microseconds, these numbers must be multiplied by the period of
CPU clock. For instance, for HC12D60 with 16Mhz oscillator, CPU clock
frequency equals 8Mhz and the CPU clock period equals 0.125
microseconds the duration of GetResource service (for “Initial” system
configuration) is 34.125 microseconds (273 * 0.125*10-6 = 34.125*10-6).
It is possible that some real numbers can slightly differ from the
A G R E E M E N T
presented values due to some last changes in OSEK OS.
Table B-1. OSEKOS_20 version of the Operating System run-time services timing
characteristics (HC12D60, Cosmic software)(1)
Conditions IR ST TW TWCS
ActivateTask
BCC1, NONPREEMPT, STATUS=STANDARD,
Counters=FALSE, Alarms=FALSE,
UnqueuedMessages=FALSE, - - 301 -
QueuedMessages=FALSE, no hook routines, no
N O N - D I S C L O S U R E
interrupts
NONPREEMPT - - 546 -
Initial - - 601 692
TerminateTask
BCC1, NONPREEMPT, STATUS=STANDARD,
Counters=FALSE, Alarms=FALSE,
UnqueuedMessages=FALSE, - 240 - -
QueuedMessages=FALSE, no hook routines, no
interrupts
NONPREEMPT - 455 - -
Initial - 447 - -
ChainTask
Table B-1. OSEKOS_20 version of the Operating System run-time services timing
characteristics (HC12D60, Cosmic software)(1)
Conditions IR ST TW TWCS
BCC1, NONPREEMPT, STATUS=STANDARD,
Counters=FALSE, Alarms=FALSE,
UnqueuedMessages=FALSE, - - - 441
QueuedMessages=FALSE, no hook routines, no
interrupts
NONPREEMPT - - - 845
Initial - - - 821
A G R E E M E N T
Schedule
BCC1, NONPREEMPT, STATUS=STANDARD,
Counters=FALSE, Alarms=FALSE,
67 - - 115
UnqueuedMessages=FALSE,
QueuedMessages=FALSE
NONPREEMPT 123 - - 266
Initial 123 - - -
GetTaskId
Initial 48 - - -
GetTaskState
Initial: running task 68
ready task 226 - - -
suspended task 266
N O N - D I S C L O S U R E
EnterISR
Resources=TRUE, FastResource=TRUE 53 - - -
LeaveISR
Resources=TRUE, FastResource=TRUE 114 - - -
EnableInterrupt
Resources=TRUE, FastResource=TRUE 33 - - -
DisableInterrupt
Resources=TRUE, FastResource=TRUE 32 - - -
GetInterruptMask
Resources=TRUE, FastResource=TRUE 26 - - -
GetResource
Resources=TRUE, FastResource=TRUE 97 - - -
ReleaseResource
Resources=TRUE, FastResource=TRUE 151 - - 353
R E Q U I R E D
Table B-1. OSEKOS_20 version of the Operating System run-time services timing
characteristics (HC12D60, Cosmic software)(1)
Conditions IR ST TW TWCS
SetEvent
ECC1, NONPREEMPT 102 - 144 -
ECC1 102 - 180 280
ClearEvent
ECC1, NONPREEMPT 29 - - -
ECC1 29 - - -
A G R E E M E N T
GetEvent
ECC1, NONPREEMPT 98 - - -
ECC1 98 - - -
WaitEvent
ECC1, NONPREEMPT 38 169 - -
ECC1 38 187 - -
(2)
SendMessage
BCC1, an unqueued message with copy 107 - - -
(2)
ReceiveMessage
BCC1, an unqueued message with copy 111 - - -
(3)
SendMessage
N O N - D I S C L O S U R E
BCC1, queued message, 1 receiver 209 - - -
(3)
ReceiveMessage
BCC1, queued message, 1 receiver 250 - - -
InitCounter
Resources=TRUE, FastResource=TRUE 128 - - -
(4)
CounterTrigger
Resources=TRUE, FastResource=TRUE 151 - 741 869
GetCounterValue
Resources=TRUE, FastResource=TRUE 107 - - -
GetCounterInfo
Resources=TRUE, FastResource=TRUE 82 - - -
(4)
SetRelAlarm
Resources=TRUE, FastResource=TRUE 188 - 682 808
(4)
SetAbsAlarm
Table B-1. OSEKOS_20 version of the Operating System run-time services timing
characteristics (HC12D60, Cosmic software)(1)
Conditions IR ST TW TWCS
Resources=TRUE, FastResource=TRUE 220 - 714 840
CancelAlarm(4)
Resources=TRUE, FastResource=TRUE 100 - - -
GetAlarm(4)
Resources=TRUE, FastResource=TRUE 100 - - -
1. In all configurations number of task objects is 5.
A G R E E M E N T
C.1 Contents
C.2 Memory for the OSEK Operating System. . . . . . . . . . . . . . . .289
A G R E E M E N T
C.3 Data Sheet for the Cosmic . . . . . . . . . . . . . . . . . . . . . . . . . . .292
N O N - D I S C L O S U R E
memory requirements:
OSVERSION = 2;
TargetMCU = HC12;
HCBankCode = FALSE;
HCBasePage = TRUE;
HCLowPower = FALSE;
CC = BCC1;
EntryExitISR = FALSE;
InterruptMaskControl = FALSE;
SCHEDULE = FULL;
SimpleScheduler = TRUE;
UseMainStack = FALSE;
UseSameContext = TRUE;
MultiplyActivation = FALSE;
TaskIndexMethod = FALSE;
TaskBasePage = TRUE;
NodeStack = FALSE;
StackPool = FALSE;
TaskOwnStack = TRUE;
PersistentNode = FALSE;
PersistentStack = FALSE;
STATUS = STANDARD;
HookRoutines = FALSE;
ErrorHook = FALSE;
StartupHook = TRUE;
ShutdownHook = TRUE;
PreTaskHook = FALSE;
PostTaskHook = FALSE;
InternalErrorHandler = FALSE;
Resources = FALSE;
FastResource = FALSE;
Events = FALSE;
A G R E E M E N T
Counters = FALSE;
CounterSize = 8;
Alarms = FALSE;
AlarmList = FALSE;
UnqueuedMessages = FALSE;
UnqueuedMsgDefaultValue = FALSE;
QueuedMessages = FALSE;
QueuedMsgOneToN = FALSE;
ActivateOnMsg = FALSE;
AlarmOnMsg = FALSE;
SetEventOnMsg = FALSE;
This initial property list was used for the first row in the table. It conforms
to the BCC1 Conformance Class without any additional mechanisms
and this is the minimal OSEK OS configuration. The rows below reflects
memory requirements for the next Conformance Classes. System
N O N - D I S C L O S U R E
properties are shown in the rows which are turned on for the
corresponded Conformance Class. For BCC2, ECC1, ECC2 the
scheduler policy is full-preemptive one.
All other rows below the first one (“Initial”) has a title “Initial” or
“Changed:” and one or more options turned ON or OFF. If a row has a
title “Initial” it means that for such OS configuration the Initial property list
is used with particular options changed as shown. If a row has a title
“Changed:” it means that for such OS configuration the setting list as for
the previous row is used with particular options changed as shown.
Thus, the system functionality grows up.
Under the title “Extensions” the additions are shown for each additional
system property (or group of them). These numbers are got on the base
of ECC2 configuration. For example, the row “Counters = ON” presents
the additional memory requirements for this mechanism. It allows the
R E Q U I R E D
user to evaluate the amount of memory needed to support some
particular mechanisms and features. Differences between the amount of
memory required to support these features for various Conformance
Classes are comparatively small. Therefore, the data is provided only for
ECC2. Thus, since each next row includes all functionality of the
previous ones, the last row presents the memory requirements for the
system with full functionality.
A G R E E M E N T
the exact memory amount for each case. These formulas are provided
in the table.
NOTE: In the formulas in the table the following symbols are used:
N O N - D I S C L O S U R E
• P is the number of tasks’ priorities;
• R is the number of resources;
• Sp is the number of stack pools;
• Sb is the number of stack buffers.
It is possible that some real numbers can slightly differ from the
presented values due to some last changes in OSEK OS.
Initial
3 SCHEDULE = MIXED - 894+7*Tt 23+9*Ts
UseSameContext = FALSE
Changed:
4 HCBasePage = FALSE 23+7*Ts 890+7*Tt -
TaskBasePage = FALSE
Changed: BCC1
5 21+7*Ts 1001+10*Tt -
STATUS = EXTENDED
Changed:
6 21+7*Ts 1001+10*Tt -
ErrorHook = TRUE
Changed:
STATUS = STANDARD
7 25+7*Ts 1056+7*Tt -
ErrorHook = FALSE
EntryExitISR = TRUE
Changed:
N O N - D I S C L O S U R E
8 27+7*Ts 1165+8*Tt -
InterruptMaskControl = TRUE
Changed:
081 27+7*Ts 1191+10*Tt -
Reconfig = TRUE
Initial
9 - 936+7*Tt 29+10*Ts+4*P
SimpleScheduler = FALSE
Changed:
10 HCBasePage = FALSE 29+10*Ts+4*P 991+7*Tt -
TaskBasePage = FALSE
Initial
11 SimpleScheduler = FALSE - 1266+11*Tt 31+10*Ts+4*P
MultiplyActivation = TRUE BCC2
Changed:
12 HCBasePage = FALSE 31+10*Ts+4*P 1330+11*Tt -
TaskBasePage = FALSE
Changed:
13 29+10*Ts+4*P 1456+14*Tt -
STATUS = EXTENDED
Changed:
14 29+10*Ts+4*P 1541+14*Tt -
ErrorHook = TRUE
R E Q U I R E D
Table C-1. OSEKOS_20 version of the Operating System memory requirements
Confor-
System Properties Base Page
Number mance ROM RAM
(configuration) RAM
Class
Initial
15 SimpleScheduler = FALSE - 1075+7*Tt 29+12*Ts+4*P
Events = TRUE
Changed:
16 HCBasePage = FALSE 29+12*Ts+4*P 1135+7*Tt -
TaskBasePage = FALSE
Changed:
17 27+12*Ts+4*P 1336+10*Tt -
STATUS = EXTENDED
A G R E E M E N T
ECC1
Changed:
18 27+12*Ts+4*P 1502+10*Tt -
ErrorHook = TRUE
Changed:
STATUS = STANDARD
19 31+12*Ts+4*P 1349+7*Tt -
ErrorHook = FALSE
EntryExitISR = TRUE
Changed:
20 33+12*Ts+4*P 1494+8*Tt -
InterruptMaskControl = TRUE
Initial
SimpleScheduler = FALSE
21 ECC2 - 1407+11*Tt 31+12*Ts+4*P
MultiplyActivation = TRUE
Events = TRUE
N O N - D I S C L O S U R E
Changed: 1562+11*Tt+3
22 2*R 31+14*Ts+4*P
Resources = TRUE *R
Changed:
23 - 1546+11*Tt 33+12*Ts+4*P
FastResource = TRUE
Changed: 1666+11*Tt+4
24 1*C 33+12*Ts+4*P
A G R E E M E N T
Counters = TRUE *C
Changed: 1674+11*Tt+6
25 2*C 33+12*Ts+4*P
CounterSize = 16 *C
Changed: 1716+11*Tt+1
26 4*C 33+12*Ts+4*P
CounterSize = 32 0*C
Changed:
2108+11*Tt+6
27 Alarms = TRUE 3*C+8*A 33+12*Ts+4*P
*C+7*A
CounterSize = 8
Changed: 2115+11*Tt+4
28 3*C+11*A 33+12*Ts+4*P
AlarmList = TRUE *C+7*A
Changed: 3*C+11*A+3* 2445+11*Tt+4
29 33+12*Ts+4*P
UnqueuedMessages = TRUE S *C+7*A+5*S
Changed: 3*C+11*A+3* 2478+11*Tt+4
30 ECC2 33+12*Ts+4*P
UnqueuedMsgDefaultValue = TRUE S *C+7*A+7*S
N O N - D I S C L O S U R E
2711+11*Tt+4
Changed: 3*C+11*A+3*
31 *C+7*A+7*S+ 33+12*Ts+4*P
QueuedMessages = TRUE S+39*E
11*E
2830+11*Tt+4
Changed: 3*C+11*A+3*
32 *C+7*A+7*S+ 33+12*Ts+4*P
QueuedMsgOneToN = TRUE S+39*E
15*E
2891+11*Tt+4
Changed: 3*C+11*A+3*
33 *C+7*A+10*S 33+12*Ts+4*P
ActivateOnMsg = TRUE S+39*E
+18*E
2907+11*Tt+4
Changed: 3*C+11*A+3*
34 *C+7*A+10*S 33+12*Ts+4*P
SetEventOnMsg = TRUE S+39*E
+18*E
3052+11*Tt+4
Changed: 3*C+11*A+3*
35 *C+7*A+13*S 33+12*Ts+4*P
AlarmOnMsg = TRUE S+39*E
+21*E
3218+11*Tt+1
Changed: 4*Sp+3*C+11*
36 0*Sp+4*C+7* 33+14*Ts+4*P
StackPool = TRUE A+3*S+43*E
A+13*S+21*E
R E Q U I R E D
Table C-1. OSEKOS_20 version of the Operating System memory requirements
Confor-
System Properties Base Page
Number mance ROM RAM
(configuration) RAM
Class
3265+11*Tt+1
Changed: 4*Sp+3*C+11*
37 0*Sp+4*C+7* 33+16*Ts+4*P
NodeStack = TRUE A+3*S+47*E
A+13*S+21*E
3348+13*Tt+1
Changed: 4*Sp+3*C+11*
38 0*Sp+4*C+7* 33+16*Ts+4*P
PersistentNode = TRUE A+3*S+47*E
A+13*S+21*E
3390+13*Tt+1
4*Sp+3*C+11*
A G R E E M E N T
Changed:
39 0*Sp+4*C+7* 33+16*Ts+4*P
PersistentStack = TRUE A+3*S+47*E
A+13*S+21*E
33+16*Ts+4*P
Changed: 3430+13*Tt+1
+4*Sp+3*C+1
40 HCBasePage = FALSE 0*Sp+4*C+7* -
TaskBasePage = FALSE
1*A+3*S+47*
A+13*S+21*E
E
31+16*Ts+4*P
ECC2 4058+16*Tt+1
Changed: +4*Sp+3*C+1
41 0*Sp+7*C+7* -
STATUS = EXTENDED 3*A+5*S+47*
A+13*S+21*E
E
31+16*Ts+4*P
4431+16*Tt+1
Changed: +4*Sp+3*C+1
42 0*Sp+7*C+7* -
ErrorHook = TRUE 3*A+5*S+47*
A+13*S+21*E
E
33+16*Ts+4*P
5125+16*Tt+1
N O N - D I S C L O S U R E
Changed: +4*Sp+3*C+1
43 0*Sp+7*C+7* -
EntryExitISR = TRUE 3*A+5*S+49*
A+13*S+21*E
E
35+16*Ts+4*P
5349+17*Tt+1
Changed: +4*Sp+3*C+1
44 0*Sp+7*C+7* -
InterruptMaskControl = TRUE 3*A+5*S+51*
A+13*S+21*E
E
D.1 Contents
D.2 Error Message Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .297
A G R E E M E N T
D.3 Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .297
D.4 Warning Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314
N O N - D I S C L O S U R E
NN presents the group number,
## presents the error number inside the group.
An error message includes the file name, the line number, the error code
and a short error (or warning) description. The error message has one of
the following formats:
Below all System Generator error and warning messages are described.
A syntax error was found in the input stream. Problems of this type can
sometimes be attributed to a syntactical or clerical error. For example:
TASK taskA
{
PRIORITY = 5 // No closing semicolon
SCHEDULE = FULL;
};
In the preceding example, the error message will be generated for the
line which contains the definition of SCHEDULE attribute, although the
true source of the error appears on the line just above. As a general rule,
A G R E E M E N T
make sure to also examine the lines above the line listed in the error
message when trying to determine the cause.
The system generator found the end of a file while scanning a comment.
This error can also be caused by a comment on the last line of a source
file that is not followed by the ‘CR’ symbol as in the example:
N O N - D I S C L O S U R E
To eliminate this error, go to the end of the line and add a new line.
The system generator reached the end of a source file without resolving
a construct.
To break a string constant that is on two lines in the source file, end the
first line with the line-continuation character, a backslash.
R E Q U I R E D
E0011: cannot open source file: <name>
cannot open include file: <name>
cannot open output file: <name>
This file either did not exist, could not be opened, or was not found.
There are three possible reasons of that:
– This error can occur if the file, subdirectory, or disk on which it resides
is read-only. In this case, make the file writable or move the file to a
writable disk.
A G R E E M E N T
– Trying to open a file or directory for which you do not have permission
can cause this error.
N O N - D I S C L O S U R E
An error occurred while SG was trying to write into the file.
An error occurred while the system generator was trying to write to the
output file. The cause of this error is insufficient disk space.
The system generator could not find template file for use in the
generation process because the command-line option or
SYSGEN_TEMPLATE environment variable was set to an invalid
filename.
To eliminate this error, either correct command line or use the SET
command to change the SYSGEN_TEMPLATE environment variable so
that it points to a valid filename.
Incorrect name was defined for object. The first character of an identifier
name must be an underscore or an uppercase or lowercase letter. The
A G R E E M E N T
R E Q U I R E D
The standard OIL format is intended to define simple application inside
separate CPU without using object library and configuration.
The CFGACTIVE attribute was defined while the CFG with desired
name was not detected.
A G R E E M E N T
CPU <cpu>: Same name for several object inside Cpu: <name>
The given name has already been used for a system object of the other
type.
N O N - D I S C L O S U R E
OIL
E0050: CPU <name>: More than one OS defined inside local object
CPU <name>: More than one OS defined inside cfg: <name>
Either the CPU specified in command line was not found in the file or no
CPU was defined in the file.
The PCFGACTIVE attribute was defined while the PCFG with desired
name was not detected.
The setting for CPU or NETWORK was defined inside PCFG but the
referenced CFG was not defined for defined object.
The setting for CPU or Network was defined inside PCFG but neither
CPU nor NETWORK with the name was defined.
The given identifier was defined twice inside table (either Constant or
Project configuration table). The system generator used the second
definition.
R E Q U I R E D
The configuration for given CPU was defined twice inside Project
configuration table. The system generator used the second definition.
More than one Implementation definition was found in the input file.
A G R E E M E N T
E0072: Redefined type of referenced object does not correspond to
previously defined
N O N - D I S C L O S U R E
make a sense.
R E Q U I R E D
E0106: SimpleScheduler property can not be used with Resources
property
A G R E E M E N T
E0110: interrupt masks shall be defined
The EntryExitISR property is turned on, but the interrupt stack is not
defined.
N O N - D I S C L O S U R E
supported for the BCC1 and ECC1 conformance classes.
The ErrorHook property is turned on, but the error hook is not defined.
N O N - D I S C L O S U R E
The StartupHook property is turned on, but the startup hook is not
defined.
The ShutdownHook property is turned on, but the shutdown hook is not
defined.
R E Q U I R E D
E0160: Reconfig property turned off, no application mode
supported
More than one application modes are defined but Reconfig property is
turned off. Either turn Reconfig property on or change definition of
application mode set.
A G R E E M E N T
The MaxPrio attribute is equal to 0.
N O N - D I S C L O S U R E
The number of task control blocks are less than maximum of task
priority, it is not enough in case of SimpleScheduler.
The defined task priority is greater than MaxPrio attribute defined for OS.
The number of tasks with persistent node are greater than the number
of nodes. Also this error is caused when the number of tasks with
persistent node is equal to number of nodes and there are at least one
more tasks.
A task has the defined POOLSTACK stack attachment method, but the
StackPool reference has not been defined.
event setting.
A task has the defined NODESTACK stack attachment method, but the
NodeStack property is turned off.
A task has the defined POOLSTACK stack attachment method, but the
StackPool property is turned off.
N O N - D I S C L O S U R E
The ACTIVATION attribute has the value greater than 1, but according
to OSEK OS spec. 2.0 multiple task activation is not supported in the
R E Q U I R E D
BCC1 and ECC1 conformance classes for BACIS task and never
supported for EXTENDED task.
A G R E E M E N T
E0318: task scheduling type shall be defined
The task type is not defined. The TYPE attribute is obligatory for TASK
object.
N O N - D I S C L O S U R E
E0321: number of task activations shall be defined
A task has the defined OWNSTACK stack attachment method, but the
TaskOwnStack property is turned off.
The simplified scheduler can be used only if each task in the application
has an unique priority.
A G R E E M E N T
Size of buffer in the pool shall be defined for the STACK object.
Number of buffers in the pool shall be defined for the STACK object.
If an event has AUTO as mask, then some task should have reference
to this event.
The ISR of category 3 has the ISR-frame which is started with EnterISR
and finished by ExitISR call. The pair of function is obligatory for ISR of
category 3.
R E Q U I R E D
The EVENT object is defined, but one of the BASIC conformance
classes is defined for OS.
Only one of the defined counters shall have the SystemTimer attribute
TRUE.
A G R E E M E N T
E0502: System timer is undefined
The TICKDURATION attribute is not defined for system timer. The value
of this attribute is used for definition of the OSTICKDURATION constant.
N O N - D I S C L O S U R E
The TICKSPERBASE attribute is obligatory for COUNTER object.
The ALARM has the reference to EVENT while one of the BASIC
A G R E E M E N T
R E Q U I R E D
E0716: task to event setting shall be defined
The event setting notification method is defined but the TASK reference
is not defined.
The EVENT reference is defined for message while one of the BASIC
conformance classes has been defined for OS.
A G R E E M E N T
The ITEMS attribute has value greater than 1 for unqueued message.
N O N - D I S C L O S U R E
E0722: task notification method is NONE, task shall not be defined
The <flag> in the command-line option is not valid; the option is ignored.
The attribute <name> has been previously defined and will be re-
defined.
The reference <name> has been previously defined and will be re-
defined.
The UseMainStack property is turned on, but either the scheduler stack
or the interrupt stack is defined.
The ErrorHook property is turned off, but the error hook is defined.
R E Q U I R E D
W0122: StartupHook property turned off, definition ignored
The StartupHook property is turned off, but the startup hook is defined.
W0150: NetworkCOM property turned on, but this version does not
support COM generation, definition ignored
A G R E E M E N T
The NetworkCOM property is turned on, but this version of system
generator does not support generation of COM objects.
If the NodeStack property is turned off then the node stacks are not
supported and parameters defining this stack are ignored.
The number of task control blocks are greater than maximum defined
priority of a task, therefore in case of SimpleScheduler the unused
control blocks exist.
N O N - D I S C L O S U R E
The MultiplyActivation property is set to FALSE but the task has
ACTIVATION greater than 1.
The STACK object is defined, but the StackPool property turned off.
The EVENT object is defined, but the Events property of OS turned off.
R E Q U I R E D
W0503: TICKDURATION attribute is applied for system timer only,
parameter ignored
If the counter is not the system timer then the definition of the
TICKDURATION is ignored.
The Alarms property of OS is turned off but the ALARM object is defined.
A G R E E M E N T
QueuedMessages property is turned off, definition ignored
N O N - D I S C L O S U R E
The number of receivers is greater than one, but QueuedMsgOneToN is
turned off.
The ReceiverNum attribute is defined for state message and has value
greater than 1.
A G R E E M E N T
E.1 Contents
E.2 System Services Quick Reference . . . . . . . . . . . . . . . . . . . . .319
A G R E E M E N T
E.3 OIL language Quick Reference . . . . . . . . . . . . . . . . . . . . . . .325
N O N - D I S C L O S U R E
syntax: StatusType ActivateTask(TaskType <TaskName>);
– – No
TerminateTask
syntax: StatusType TerminateTask(void);
Task name – No
ChainTask
syntax: StatusType ChainTask(TaskType <TaskName>);
– – No
Schedule
syntax: StatusType Schedule(void);
– Task name No
GetTaskId
syntax: StatusType GetTaskId(TaskRefType <TaskName>);
Task name Task state Yes
GetTaskState syntax: StatusType GetTaskState(TaskType <TaskName>,
TaskStateRefType <State>);
– Task Control Block Yes
GetTCBInfo1
syntax: StatusType GetTCBInfo(TaskControlBlockRefType <Tcb>);
Interrupt management services
DisableInterrupt
syntax: StatusType DisableInterrupt(IntDescriptorType <Descr>);
– Interrupt descriptor Yes
GetInterruptDescriptor
syntax: StatusType GetInterruptDescriptor(IntDescriptorRefType <Descr>);
Resource management services
Resource name – No
GetResource
syntax: StatusType GetResource(ResourceType <ResName>);
Resource name – No
ReleaseResource
syntax: StatusType ReleaseResource(ResourceType <ResName>);
Event control services
Task name, Event mask – Yes
SetEvent syntax: StatusType SetEvent (TaskType <TaskName>,
EventMaskType <Mask>);
N O N - D I S C L O S U R E
Event mask – No
ClearEvent
syntax: StatusType ClearEvent(EventMaskType <Mask>);
Task name Event mask Yes
GetEvent syntax: StatusType GetEvent(TaskType <TaskName>,
EventMaskRefType <Mask>);
Event mask – No
WaitEvent
syntax: StatusType WaitEvent(EventMaskType <Mask>);
Message management services
Message name, message data – Yes2
SendMessage syntax: StatusType SendMessage( SymbolicName <Message>,
AccessName <Data>);
Message name Message data Yes/No3
ReceiveMessage syntax: StatusType ReceiveMessage(SymbolicName <Message>,
AccessName <Data>);
Message name – No
GetMessageResource
syntax: StatusType GetMessageResource(<MessageName>);
R E Q U I R E D
Table E-1. OSEK OS services
Service Input Output ISR
Message name – No
ReleaseMessageResource
syntax: StatusType ReleaseMessageResource(<MessageName>);
Message name – Yes
GetMessageStatus
syntax: StatusType GetMessageStatus(<MessageName>);
Counter management services
Counter name, initial value – No
InitCounter syntax: StatusType InitCounter(CtrRefType <CtrName>,
TickType <Ticks>);
A G R E E M E N T
Counter name – Yes
CounterTrigger
syntax: StatusType CounterTrigger(CtrRefType <CtrName>);
Counter name, number of ticks – No
AdvanceCounter4 syntax: StatusType AdvanceCounter(CtrRefType <CtrName>,
TickType <Ticks>);
Counter name Counter value No
GetCounterValue syntax: StatusType GetCounterValue(CtrRefType <CtrName>,
TickRefType <Ticks>);
Counter name Counter constants No
GetCounterInfo syntax: StatusType GetCounterInfo(CtrRefType <CtrName>,
CtrInfoRefType <Info>);
Alarm management services
Alarm name Alarm constants Yes
N O N - D I S C L O S U R E
GetAlarmBase syntax: StatusType GetAlarmBase(AlarmType <AlarmName>,
AlarmBaseRefType <Info>);
Alarm name, Counter relative value,
– Yes
Cycle value
SetRelAlarm
syntax: StatusType SetRelAlarm (AlarmType <AlarmName>,
TickType <Increment>, TickType <Cycle>);
Alarm name, Counter absolute value,
– Yes
Cycle value
SetAbsAlarm
syntax: StatusType SetAbsAlarm (AlarmType <AlarmName>,
TickType <Start>, TickType <Cycle>);
Alarm name – Yes
CancelAlarm
syntax: StatusType CancelAlarm(AlarmType <AlarmName>);
Relative value in ticks before the
Alarm name Yes
alarm expires
GetAlarm
syntax: StatusType GetAlarm(AlarmType <AlarmName>,
TickRefType <Ticks>);
Hook Routines
Error code – Yes
ErrorHook
syntax: void ErrorHook(StatusType <Error>);
– – Yes
PreTaskHook
syntax: void PreTaskHook(void );
– – Yes
PostTaskHook
syntax: void PostTaskHook(void );
– – No
IdleLoopHook
syntax: void IdleLoopHook(void );
– – No
StartupHook
syntax: void StartupHook(void );
– – No
N O N - D I S C L O S U R E
ShutdownHook
syntax: void ShutdownHook(void );
1. This service is not defined in the OSEK OS v.2.0 rev. 1 specification. This is an extension of OSEK OS.
3. Yes – for unqueued messages in WithCopy configuration only, No – for queued messages.
4. This service is not defined in the OSEK OS v.2.0 rev. 1 specification. This is an extension of OSEK OS.
R E Q U I R E D
Table E-2. Data Types
Data Type Description
TaskStateType The data type for variables to store the state of a task
TaskStateRefType The data type to refer variables of the TaskStateType data type
TaskControlBlockType The data type for task control block (task node)
TaskControlBlockRefType The data type to refer variables of the TaskControlBlockType data type
IntDescriptorType The data type for logical interrupt descriptors
IntDescriptorRefType The date type to refer variables of the IntDescriptorType data type
ResourceType The abstract data type for referencing a resource
A G R E E M E N T
EventMaskType The data type of the event mask
EventMaskRefType The data type to refer to an event mask
CtrRefType The data type references a counter
TickType The data type represents a counter value in system ticks
TickRefType The data type references data corresponding to the data type TickType
The data type represents a structure for storage of counter characteristics. This structure has
the following fields:
maxallowedvalue maximum possible allowed count value;
CtrInfoType
ticksperbase number of ticks required to reach a counter-specific significant unit;
mincycle minimum allowed number of ticks for a cyclic alarm (only for system with Extended
Status);
CtrInfoRefType The data type references data corresponding to the data type CtrInfoType
The data type represents a structure for storage of alarm characteristics. It is the same as
AlarmBaseType
CtrInfoType
N O N - D I S C L O S U R E
AlarmBaseRefType The data type references data corresponding to the data type AlarmBaseType
AlarmType The data type represents an alarm element
AppModeType This data type represents the operating mode
SymbolicName An unique name representing a message
AccessName An unique name defining access to a message object
The table below contains all return values for OSEK Operating System
run-time services and error values.
Table E-4. OSEK Operating System run-time services return values and error values
Name Value Type
E_OK 0 No error, successful completion
N O N - D I S C L O S U R E
R E Q U I R E D
The following table contains OSEK Operating System constants with
short description.
A G R E E M E N T
Constant of data type TaskStateType for task state
SUSPENDED 3
suspended
Constant of data type TaskType for a not defined
INVALID_TASK (TaskType)–1
task
(ResourceType)0
If Resource = FALSE or
FastResource = FALSE in
configuration OIL-file Constant of data type ResourceType for Scheduler
RES_SCHEDULER
(ResourceType)–1 as a resource
If Resource = TRUE and
FastResource = TRUE in
configuration OIL-file
OSMAXALLOWEDVALUE Maximum possible allowed count value
OSTICKPERTIME Number of ticks that are required to reach 10
OSTICKSPERBASE milliseconds in the system timer
N O N - D I S C L O S U R E
Number of ticks required to reach a counter-specific
OSTICKDURATION Depends on user’s settings
significant unit
in configuration OIL-file
Minimum allowed number of ticks for a cyclic alarm
OSMINCYCLE
(only for system with Extended Status)
INITIAL_INTERRUPT_
Initial interrupt level during system startup
DESCRIPTOR
The value used by default typed by the boldface type in the Possible
Values cells.
E.3.1 OS Object
Standard Attributes
OSEK Conformance Class. Defines
general OS functionality and OS
behavior. However, most features of
BCC1, BCC2, the OS may be selected by means of BCC3 Conformance Class is
CC ECC1, ECC2, using other OS additional properties. also supported in Motorola OS
AUTO Therefore, even for given conformance v.1.0.
class the functionality may be reduced
or increased according to user’s
needs.
Scheduling Policy. Determines
whether OS supports non-preemptive
task only, preemptive task only, or
both. The preemptive scheduling
allows better timing for external events, In general, the task context
while it adds overhead for more often differs for preemptive and non-
NON, FULL,
SCHEDULE context switching. For application with preemptive tasks. Preemptive
MIXED, AUTO
N O N - D I S C L O S U R E
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
Defines that user’s-provided hook is
called after the operating system start-
up and before the scheduler is running.
Particular main() function should
This hook may be used by the
not be used for OS-dependent
application to perform hardware
initialization actions like task
StartupHook TRUE, FALSE initialization actions, task activations,
activation, alarm setting,
alarm setting, etc.
because at this time OS is not
The alternative way is to make such
running.
initialization steps in the task, which
starts automatically. The hook is called
with disabled interrupts.
A G R E E M E N T
Defines that user’s-provided hook is
called when the OS shutdown service This hook is called before
is performed. The main purpose of this system timer shutdown (if
hook is to shutdown initialized system timer is configured in the
ShutdownHook TRUE, FALSE
hardware devices like timers, network system). The status of interrupts
controllers, etc. Besides, the reason for is undefined, so it should be
shutdown may be obtained through the controlled by the user.
error code.
Defines that user’s-provided hook is It is not recommended to use
called from the scheduler code before this hook in normal working
the operating system enters context of applications, because it adds
the task. In general, this hook is significant timing overhead.
PreTaskHook TRUE, FALSE
designed for debugging applications by If defined, this hook is called for
means of tracing current task. This each task, i.e. it is not allowed to
hook is called within the task or use this hook for particular
interrupt service routine. task(s) only.
Defines that user’s-provided hook is It is not recommended to use
N O N - D I S C L O S U R E
called from the scheduler code after this hook in normal working
the operating system leaves context of applications, because it adds
the task. In general, this hook is significant timing overhead.
PostTaskHook TRUE, FALSE
designed for debugging applications by If defined, this hook is called for
means of tracing current task. This each task, i.e. it is not allowed to
hook is called within the task or use this hook for particular
interrupt service routine. task(s) only.
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
Specifies that the running task This attribute is only valid for
identification in run-time support will be OSEK OS supporting ORTI (see
ORTIRunningTask TRUE, FALSE
used. This attribute will be ignored if Section 18 ORTI
DEBUG_LEVEL = 0. Implementation for the details).
Specifies that the OSEK OS system This attribute is only valid for
calls identification in run-time support OSEK OS supporting ORTI (see
ORTICurrentService TRUE, FALSE
will be used. This attribute will be Section 18 ORTI
ignored if DEBUG_LEVEL = 0. Implementation for the details).
If there is no network, then this
attribute should be defined as
A G R E E M E N T
Defines whether the COM support is FALSE to avoid overhead,
NetworkCOM TRUE, FALSE
provided by OS or not. connected with communication
code.
FALSE by default.
Supported for HC08, HC12 for
base page (address range 00 16-
FF16), and for MPC (few general
registers are used to hold often
used OS variables). It is
Defines that OS system variables will
recommended to use base page
be allocated in the base page or in
for OS system variables, if there
non-volatile registers. Depending on
is enough space in it. In this
the OS configuration, the system
case, application should be
variables consume from several bytes
linked correctly to provide
HCBasePage TRUE, FALSE to several dozens of bytes in base
proper allocation of data in base
page. The code size is decreased by
page. It is highly recommended
approximately 5%, and timing is
to use sample makefile as a
improved accordingly, because
basis for using this attribute
N O N - D I S C L O S U R E
addressing to base page usually takes
properly (in compiler/linker
less space and processor cycles.
settings).
However, some MCUs use base
page for input-output registers,
which prevents the using of it for
variables.
Defines that the support of Bank
Switching is used in the OSEK Supported for HC12 only. It is
OS. The microcontroller memory bank not recommended to use this
HCBankCode TRUE, FALSE hardware should be supported by the feature, if there is no need to
compiler. locate application into the
This is useful when memory banks are banked memory.
supported by the hardware.
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
Low Power Related Attributes These OS attributes associate with support Low Power Mode
Defines that the MCU Low Power
Mode will be used instead of plain
forever no-operation when there is no
ready tasks, and scheduler goes into
idle loop. In general, it is recommended
Not supported for WINNT.
HCLowPower TRUE, FALSE to define this attribute to reduce power
consumption. However, the recovery
from the low power state to the normal
conditions (after interrupt) may take
A G R E E M E N T
more time, than recovery from normal
loop.
WAIT, DOZE, Supported for MPC and
STOP, Defines the particular Low Power MCORE only.
HCLowPowerMode
NORMAL, Mode used Applicable if HCLowPower =
SINGLE, SLEEP TRUE
Defines whether the IRQ[0:1] pin mask
HCLowPowerMask TRUE, FALSE is defined for Low Power exit logic or Supported for MPC only
not
Supported for MPC only.
Defines a mask for Low Power Exit
HCLowPowerMaskValue NONE, IRQ Applicable if HCLowPowerMask
logic
= TRUE
System Memory Related Attributes This group of OS attributes associates with system memory allocation
Specifies the number of task control
blocks (nodes), allocated in the
system. For every ready task separate
AUTO if undefined, and number
N O N - D I S C L O S U R E
control block should be used, therefore
of nodes will be equal to the
this value should be big enough to
number of tasks, defined in
support all ready tasks. However, the
application. It is highly
same task control block may be used
NodeNumber integer recommended to set this value
by several tasks, if they are not
explicitly to avoid overhead
activated simultaneously. In general,
connected with consuming to
the task control blocks are assigned
much RAM for each task, which
dynamically to the task, when it is
are not run in the same time.
activated. In addition, several attributes
may be used to provide persistent link
between task and task control block.
AUTO if undefined.
Specifies the number of task priorities.
In spite, that system generator
In general, there is no relations
compacts the priority range, it is
between number of task control blocks
MaxPrio integer highly recommended to keep
unless SimpleScheduler attribute is
the priority range as small as
defined TRUE. In the last case these
possible. This will make
numbers should be equal.
debugging easy.
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
Defines the support of task control AUTO if undefined.
block stacks in the operating system It is highly recommended to set
code. If this parameter is set to FALSE, this parameter to FALSE, if task
NodeStack TRUE, FALSE some another stack mechanism (stack control block stacks are not
pool, static stack) should be configured used by no one task. This way,
to protect the system from crash due to both code size as well as RAM
lack of stack. consumption will be decreased.
Specifies the size of the stack (in
bytes) per each task control block. In
Ignored if
general, each task control block has its
NodeStack = FALSE.
A G R E E M E N T
own stack with fixed size. Therefore,
If any task control block may be
the simplest way is to define this
NodeStackSize integer used by any task, this parameter
attribute, and use task control block
should be big enough to satisfy
stack for ready tasks. However, the
requirements of the task, which
memory consumption is not optimized
comsumes biggest stack.
in this case, because every task may
have different stack requirements.
Specifies the bottom of task control
block stacks. This parameter may be Ignored if
used, if there is a need to allocate task NodeStack = FALSE.
NodeStackAddress string control blocks stack array in particular The task control block stack
memory section. (For example, to area is allocated as continuous
utilizes different areas of the RAM in block of memory.
the microcontroller memory map).
Clears outstanding reservations
This attribute is supported for
ClearReservation TRUE, FALSE between processes.
MPC only.
N O N - D I S C L O S U R E
Task Related Attributes This group of OS attributes controls task feature
The FALSE attribute disables task
multiple activation. This feature is
Valid only if
useful, if there is a need to have an
CC = BCC2, ECC2;
extended conformance class, but to
AUTO if undefined.
exclude multiple activation of the tasks.
MultiplyActivation TRUE, FALSE It is highly recommended to
In this case the attribute decreases
define this attribute unless
code size, and task control block size,
multiple activation is required in
as well as eliminates some variables,
the application.
connected with tracking of order of task
activations.
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
When set to TRUE, allows persistent
task stack allocation. The persistent
task stack is the stack from the stack
pool, which is explicitly assigned
AUTO if undefined.
(allocated) to the task. This persistent
The distribution of the persistent
task stack improves the timing,
stacks is rather complicated
because no run-time allocating/freeing
PersistentStack TRUE, FALSE task, therefore these pools are
of task stack is required. However, the
recommended for experienced
persistent stack can not be used by
users.
any other task in application, even
when the task is suspended. The task
A G R E E M E N T
stack may be made persistent for the
task, only if this task has persistent
task node.
AUTO if undefined.
In spite, that same memory area
may be used by several tasks, if
When set to TRUE, allows the explicit only one of them is activated in
task stack allocation. The explicit task the given time, it is
stack is a static memory area, which is recommended to avoid such
used by the task for stack. This feature configurations.
TaskOwnStack TRUE, FALSE improves the timing, because no The own stack of the task is the
dynamic operations are involved into easiest way to watch the stack
the task activating/terminating. status, because it is absolutely
However, the stack memory area can clear where the stack is located.
not be used for any other tasks. Therefore, it is recommended to
use this feature if there are
troubles, connected with the
stack overflow.
N O N - D I S C L O S U R E
Defines whether the some run-time
context frame is used both for non-
Valid only if
preemptive and preemptive tasks.
SCHEDULE=MIXED.
When set to TRUE, decreases code
It is highly recommended to set
UseSameContext TRUE, FALSE size and improves timing. However,
this attribute to TRUE. This
more stack is required for non-
simplifies debugging of the
preemptive task context, because
application.
preemptive context is used for any
task.
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
Specifies the assembler macro for
saving extended registers into non-
preemptive task context. It should be a
SaveNonPreemptCtxExt string
STRING which contains inline
assembler statements for saving
extended registers
Specifies the assembler macro for Supported for CPU32 only.
restoring extended registers from non- Valid only if ExtendedContext =
preemptive task context. It should be a TRUE.
RestoreNonPreemptCtxExt string These parameters allow
STRING which contains inline
experienced user to optimize
A G R E E M E N T
assembler statements for restoring
extended registers task context depending on the
application code and compiler
Specifies the assembler macro for behavior. It these parameters
saving extended registers into are not used and
preemptive task context. It should be a ExtendedContext = TRUE, then
SavePreemptCtxExt string
STRING which contains inline task context contains all
assembler statements for saving extended registers.
extended registers
Specifies the assembler macro for
restoring extended registers from
preemptive task context. It should be a
RestorePreemptCtxExt string
STRING which contains inline
assembler statements for restoring
extended registers
Interrupt Related Properties This group of OS attributes defines parameters of ISR execution
If no ISR which call system
service are used in the
N O N - D I S C L O S U R E
Defines whether OS provides ISR
application, it is recommended
support or not. In general, this attribute
to set this attribute to FALSE.
EntryExitISR TRUE, FALSE should be set to TRUE, if the
This will decrease the code size
application has interrupt service
and will improve timing, because
routines, which call system service.
no interrupt-level checks are
performed in the system.
Specifies whether the ISR of category
ISRCategory1 TRUE, FALSE 1 is supported by OS or not. Currently
this attribute does not affect OS code.
Specifies whether the ISR of category
ISRCategory2 TRUE, FALSE 2 is supported by OS or not. Currently
this attribute does not affect OS code.
Specifies whether the ISR of category
ISRCategory3 TRUE, FALSE
3 is supported by OS or not.
InterruptMaskControl TRUE, FALSE interrupts, call system service, and processors which have rather
interrupts will be disabled when service simple interrupt system (like
will be completed. When this HC08 or HC12).
parameter is set to FALSE, interrupts It should be double checked,
will be re-enabled in this scenario after that all interrupt masks
system service completion. In (including interrupts masks for
addition, no interrupt descriptor each task) are defined properly
manipulation services are allowed. if this attribute is set to TRUE.
When this attribute is set to TRUE,
code size and timing is significantly
increased.
Specifies the value of Interrupt mask
DisableInterruptMask integer which corresponds to all interrupts Valid only if
disabled. InterruptMaskControl=TRUE.
Specifies the value of Interrupt mask The exact value for the
EnableInterruptMask integer which corresponds to all interrupts particular platform is described
enabled in other section of this manual.
As a general rule, the bit
N O N - D I S C L O S U R E
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
Specifies the number of extended
registers to be saved into ISR stack
ISRCtxRegNum integer
frame. It should contain value from 1 till Intended for MPC505 only, not
18 implemented yet.
Valid only if ExtendedContext =
Specifies the assembler macro for
TRUE.
saving extended registers into ISR
These parameters allow
stack frame. It should be a STRING
SaveISRCtxExt string experienced user to optimize
which contains inline assembler
ISR context depending on the
statements for saving extended
application code and compiler
registers
behavior. If these parameters
A G R E E M E N T
Specifies the assembler macro for are not used and
restoring extended registers from ISR ExtendedContext = TRUE, then
stack frame. It should be a STRING ISR stack frame contains all
RestoreISRCtxExt string
which contains inline assembler extended registers.
statements for restoring extended
registers
This attribute is intended for
UnorderedExceptions TRUE, FALSE Allow unordered exception handling.
MPC only.
Resources and Events Related Attributes These OS attributes control resources and events
Defines whether event management is
provided by OS or not. Set this
attribute to be FALSE to exclude event AUTO if undefined.
Events TRUE, FALSE
support. If the attribute is set as FALSE
then no event services will be available
in the application
Defines whether resource
N O N - D I S C L O S U R E
management is provided by OS or not.
Set this attribute to be FALSE to
AUTO if undefined.
Resources TRUE, FALSE exclude resource support. If the
attribute is set as FALSE then no
resource services will be available in
the application.
This option is strongly
recommended only for
Defines whether fast resources are
debugged applications, because
FastResource TRUE, FALSE provided by OS or not. If it is TRUE the
errors related to incorrect
system will work faster.
access and priority are not
signaled to the application.
If system has STANDARD
Defines whether E_OS_ACCESS error
status or FastResource
code is returned by GetResource
property turned on or more than
service or not. If it is TRUE, then error
ResourceAccessCheck TRUE, FALSE 8 resources (including
code will be returned in EXTENDED
Scheduler) are defined in
status based on task definition in OIL-
application, then this property
file.
should be set to FALSE.
Counters and Alarms Related Attributes This group of OS attributes controls counters and alarms features
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
The delta-list of alarms improves
timing of CounterTrigger()
service, especially if dozen of
alarms are connected to the
same counter. However, delta-
If the attribute is TRUE the running list of alarms requires much
alarms are linked into a ordered alarm more memory than table of
delta-list which decreases the time for alarms to support lists also
CounterTrigger() service if too much timing of alarm management
AlarmDeltaList TRUE, FALSE
alarms are connected to the same services like SetAbsAlarm(),
counter. If this attribute and AlarmList SetRelAlarm() and GetAlarm()
A G R E E M E N T
attribute are FALSE, table of alarms is will be increased. The setting of
used. this attribute should be balanced
between timing and memory
requirements.
Only one of the options
AlarmList and AlarmDeltaList
may be used in the application.
When FALSE no one alarm may
be cyclic (this decreases RAM
usage for alarm control blocks
Defines whether alarms are supported
CyclicAlarm TRUE, FALSE and for task stacks, as well as
by OS or not.
decreases code usage and
advances timing of alarms
services).
When FALSE alarm handling is
optimized for speed. When
turned on, the alarm control
N O N - D I S C L O S U R E
block is significantly decreased,
Defines whether the alarm handling is
MinAlarmRAM TRUE, FALSE because most information is
optimized for memory (RAM) or not.
stored into ROM. This
decreasing is especially
significant when AlarmList
attribute is set to FALSE.
These are additional OS attributes to tune the selected hardware interrupt
System Timer Related Attributes
source
Valid only if interrupt related
Defines whether the System Timer is
SysTimer TRUE, FALSE services are supported by OS,
provided by OS or not.
i.e. if EntryExitISR = TRUE.
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
AUTO if undefined.
Set this attribute as FALSE to exclude If the attribute is set to be
QueuedMessageOneToN TRUE, FALSE 1:N Queued Messages support in the FALSE then 1:N Queued
system. Messages are not supported for
the application.
If the attribute is TRUE then the task
ActivateOnMsg TRUE, FALSE activation on message arrival is AUTO if undefined.
supported for the application.
If the attribute is TRUE then the alarm
notification on message arrival is
A G R E E M E N T
AlarmOnMsg TRUE, FALSE AUTO if undefined.
supported for the application (an alarm
can be linked to message arrival).
If the attribute is TRUE then the event
notification on message arrival is
SetEventOnMsg TRUE, FALSE AUTO if undefined.
supported for the application (an event
setting is allowed on message arrival).
Hook Routines Related Attribute This OS attribute defines additional hook routines support in the system
Internal error handler is used to
catch fatal errors of the
Defines whether the internal error
InternalErrorHandler TRUE, FALSE operating system. The error
handler is implemented in OS or not.
hook is called independently of
this parameter setting.
This hook is intended for
Defines that user’s-provided hook is manipulation with hardware
called by the Operating System from registers (like COP).
IdleLoopHook TRUE, FALSE
scheduler idle loop (when there are no It is not possible to call any
N O N - D I S C L O S U R E
tasks in ready state). OSEK OS directives from this
hook.
The attribute defines entry point of the
UserCommand1 string user's command hook #1 to be called
from the OS Dispatcher thread. Supported for OS/NT with
interrupt emulation only.
The attribute defines entry point of the
It is possible to call Windows
UserCommand2 string user's command hook #2 to be called
library functions from this hooks.
from the OS Dispatcher thread.
Special mechanism to invoke
The attribute defines entry point of the hooks should be used.
UserCommand3 string user's command hook #3 to be called
from the OS Dispatcher thread.
The group of attributes is designed to exclude particular OS services. If an
attribute is FALSE the corresponding service is excluded from the OS
OS Service Related Attributes
code. Names of these attributes are the same as corresponding OS
service names
R E Q U I R E D
Table E-6. OS Parameters
Object Parameters Possible Values Description Notes
SetRelAlarm TRUE, FALSE
Set this attribute as FALSE to exclude
SetAbsAlarm TRUE, FALSE code supporting the corresponding OS
service. This will decrease the total OS Exclude Alarm
CancelAlarm TRUE, FALSE
code size. If the attribute is set to be services.
GetAlarm TRUE, FALSE FALSE then the service will be
unavailable in the application.
GetAlarmBase TRUE, FALSE
SendMessage TRUE, FALSE
Set this attribute as FALSE to exclude
ReceiveMessage TRUE, FALSE code supporting the corresponding OS
service. This will decrease the total OS
A G R E E M E N T
GetMessageResource TRUE, FALSE Exclude Messaging services.
code size. If the attribute is set to be
ReleaseMessageResource TRUE, FALSE FALSE then the service will be
unavailable in the application.
GetMessageStatus TRUE, FALSE
2. This service is not defined in the OSEK OS v.2.0 rev. 1 specification. This is an extension of OSEK OS.
Parameters of this object type define task properties. The TASK object
has the standard and Motorola’s specific attributes and references.
N O N - D I S C L O S U R E
Standard Attributes
Defines the priority of the task.
The higher task priority In the Motorola’s implementation
PRIORITY integer
corresponds to the higher value range is [0...255]
PRIORITY value
TYPE BASIC, EXTENDED Defines the task type
Defines the run-time behavior of
SCHEDULE FULL, NON
the task
Defines whether the task is
AUTOSTART TRUE, FALSE activated during the system
start-up procedure or not
The maximum number of
The value range is [1...255]
ACTIVATION integer registered activation requests
for the task
Motorola’s Specific Attributes
R E Q U I R E D
Table E-7. TASK Parameters
Object Parameters Possible Values Description Notes
If a task uses the stack from a
stack pool the reference to the
StackPool name of STACK dedicated stack pool must be
provided. The symbolic name of
the stack pool shall be pointed
A G R E E M E N T
object type define ISR properties. The ISR object has the standard
attributes and references.
N O N - D I S C L O S U R E
Reference to messages which
MESSAGESENT names of MESSAGEs
are sent by ISR
This object presents OS alarms. The ALARM object has the standard
attributes and references.
N O N - D I S C L O S U R E
R E Q U I R E D
E.3.7 COUNTER Object
A G R E E M E N T
Specifies the minimum allowed
MINCYCLE integer number of counter ticks for a cyclic
alarm linked to the counter
Specifies the number of ticks required
TICKSPERBASE integer
to reach a counter-specific value
Motorola’s Specific Attribute
By default this attribute
has the value FALSE.
Specifies whether the counter is the Note, however, that only
SystemTimer TRUE, FALSE
system timer one counter must be
defined as the system
timer
Shall be defined for
Specifies duration of a tick of the
TICKDURATION integer system counter only
system counter in nanoseconds
N O N - D I S C L O S U R E
E.3.8 MESSAGE Object
R E Q U I R E D
E.3.9 EVENT Object
The EVENT object is intended for the event management. This object
has no references.
A G R E E M E N T
N O N - D I S C L O S U R E
Index
A event 105
ALARM 163, 348 Extended OIL version 135
ACTION 163 Extended Status 37, 125, 127, 193
COUNTER 163 Extended Task 32, 41
A G R E E M E N T
EVENT 164
TASK 163 F
alarm 97 fatal errors 126
Application configuration file 134
Application Modes 168
H
hook routines 121
B
Basic Task 32, 43
BCC1 33 I
BCC2 33 Interrupt Service Routine (ISR) 73
interrupt stack frame 75
ISR 167, 347
C CATEGORY 167
Ceiling Priority 87 MESSAGESENT 167
N O N - D I S C L O S U R E
CFG 168 TYPE 167
CFGACTIVE 168 ISR frame 73
Conformance Class 32
conversion constant 94
COUNTER 162, 349 M
MAXALLOWEDVALUE 162 MESSAGE 164, 349
MINCYCLE 162 ACTION 164
SystemTimer 163 ALARMRESET 166
TICKDURATION 162 ALARMRESETTIME 165
TICKSPERBASE 162 DefaultValue 166
CPU 138 EVENT 166
ITEMS 165
ITEMTYPE 165
E ReceiverNum 166
ECC1 33 StartupAlarm 165
ECC2 33 TASK 166
EVENT 161, 351 TYPE 165
MASK 161 WithCopy 166
InitCounter 155
AlarmDeltaList 152
InitialMask 150
AlarmList 152
InternalErrorHandler 154
AlarmOnMsg 154
InterruptMaskControl 145
Alarms 152
ISRCategory1 150
CancelAlarm 156
ISRCategory2 150
CC 143
ISRCategory3 150
ChainTask 155
ISRCtxRegNum 150
ChainTaskItself 148, 155
IsrStackAddress 149
ClearEvent 155
IsrStackSize 149
CopyrightNotice 146
LeaveISR 155
Counters 152
MaxPrio 145
CounterSize 152
MinAlarmRAM 153
CounterTrigger 155
MultiplyActivation 147
CyclicAlarm 152
NodeNumber 145
N O N - D I S C L O S U R E
DisableInterrupt 155
NodeStack 147
DisableInterruptMask 150
NodeStackAddress 146
EnableInterrupt 155
NodeStackSize 145
EnableInterruptMask 150
NonPreemptCtxRegNum 148
EnterISR 155
OSVERSION 142
EntryExitISR 145
PersistentNode 148
ErrorHook 154
PersistentStack 148
Events 152
PostTaskHook 154
ExtendedContext 147
PreemptCtxRegNum 149
FastResource 151
Prescaler 153
GetActiveApplicationMode 156
PrescalerValue 153
GetAlarm 156
PreTaskHook 154
GetAlarmBase 156
QueuedMessages 153
GetCounterInfo 155
QueuedMsgOneToN 153
GetCounterValue 155
ReceiveMessage 156
GetEvent 155
Reconfig 146
GetInterruptDecsriptor 155
ReleaseMessageResource 156
GetMessageResource 156
R E Q U I R E D
ReleaseResource 155 UseSameContext 148
ResourceAccessCheck 151 WaitEvent 155
Resources 151 OSEK 21
RestoreISRCtxExt 151 OSEK Implementation Language 134
RestoreNonPreemptCtxExt 149 OSEK Run Time Interface 269
RestorePreemptCtxExt 149 OSShutDown 126
SaveISRCtxExt 150
SaveNonPreemptCtxExt 148 P
SavePreemptCtxExt 149
Priority Ceiling Protocol 87
SchedStackAddress 145
SchedStackSize 145
SCHEDULE 147 Q
A G R E E M E N T
Schedule 155 Queued Messages 111
SendMessage 156
SetAbsAlarm 156 R
SetEvent 155
ready state 41, 43
SetEventOnMsg 154
RESOURCE 160, 348
SetRelAlarm 156
PRIORITY 161
ShutdownHook 154
run time context 40
ShutdownOS 156
running state 41, 43
SimpleScheduler 144
StackPool 148
StartupHook 154 S
STATUS 144 scheduler 39, 65
SysTimer 153 simplified scheduler 66
TargetMCU 142 single activation 44
N O N - D I S C L O S U R E
TaskBasePage 148 STACK 159, 347
TaskIndexMethod 147 NumberOfStacks 160
TaskLevelMask 150 StackAreaAddress 160
TaskOwnStack 148 StackSize 160
TerminateTask 155 Stack Errors 195
TimerHardware 153 Standard OIL version 135
TimerModulo 153 Start-up Routine 128
TimerModuloValue 153 System Generator 36
UnorderedExceptions 151 System Generator utility (SG) 133
UnqueuedMessages 153 system timer 95
UnqueuedMsgDefaultValue 153
UseCommonArea 146 T
UseMainStack 144
TASK 156, 345
UseMoveBlockInstruction 147
ACTIVATION 157
UserCommand1 155
AUTOSTART 157
UserCommand2 155
EVENT 159
UserCommand3 155
InterruptMask 158
MemoryBank 158
MESSAGERECEIVED 159
MESSAGESENT 159
PersistentNode 158
PersistentStack 158
PRIORITY 157
RESOURCE 159
SCHEDULE 157
StackMethod 157
StackPool 159
STACKSIZE 157
A G R E E M E N T
TYPE 156
task configuration table 40
task control block 51
task node 40
U
Unqueued Messages 111
W
waiting state 32, 105
N O N - D I S C L O S U R E