OSEK/VDX OS改訂提案を作る

OSEK/VDX OSは、発行後改訂をしていない。

２つの選択肢がある。

命名規則など、用語の統一感をもたせるための追補を提案する。
図の生合成、具体的な事象から抽象的な事象かまたはその逆の筋書きの一貫性のために編集して新しい版に全面書き換えする。

OSEK/VDX Operating System Specification 2.2.3 
https://www.irisa.fr/alf/downloads/puaut/TPNXT/images/os223.pdf
以下、ページ番号は上記文書よりの引用。ISO本体ではなく、正式提案時は、ISO文書の記述におきかえ予定。

# 改訂候補
## Category 1 ISR(interrupt service routine, Categoly 2 ISR
-> Without OS ISR, With OS ISR
図ではこうはの名前がある。本文も用語を統一するとよい。

たとえば、AUTOSARで、時間保護のための割り込みを、従来のWithoutOS ISRの中に作るとすれば、Without OS ISR, Without OS ISR(under time protection ISR), With OS ISRという名称にすればよく、従来の名前の意味が変わることはない。

## ISR first
割り込みの記述は、タスクの記述よりも先にする。

OSCNagoyaで、OSで最初にタスクを記述している本は嫌いだと言ったら、この本は違うと著者から勧めてもらったことがある。

12ステップで作る組込みOS自作入門 坂井 弘亮
https://qiita.com/kaizen_nagoya/items/6333a377689a090e257b

ハードウェアの抽象化の段階をふまずに、上からOSが偉いという感じの記述が嫌だったのかもしれない。

## TASK
Basic TasksをExtended Tasksの前に置く。
拡張を基本の前に説明するってどうよってなったことがある。

## 関数の体系化
callback, callout, reentrant, recursive, fook, 


### 現行
>Table of Contents
1 Introduction. 1
1.1 System philosophy . 6
1.2 Purpose of this document . 8
1.3 Structure of this document . 9
2 Summary. 11
3 Architecture of the OSEK operating system. 12
3.1 Processing levels .. 12
3.2 Conformance classes .. 13
3.3 Relationship between OSEK OS and OSEKtime OS .. 15
4 Task management . 16
4.1 Task concept. 16
4.2 Task state model. 16
4.2.1 Extended tasks .. 16
4.2.2 Basic tasks. 18
4.2.3 Comparison of the task types.. 18
4.3 Activating a task. 19
4.4 Task switching mechanism .. 19
4.5 Task priority . 19
4.6 Scheduling policy. 20
4.6.1 Full preemptive scheduling. 20
4.6.2 Non preemptive scheduling .. 21
4.6.3 Groups of tasks . 22
4.6.4 Mixed preemptive scheduling. 23
4.6.5 Selecting the scheduling policy .. 23
4.7 Termination of tasks. 23
5 Application modes .. 24
5.1 Scope of application modes.. 24
5.2 Start up performance .. 24
5.3 Support for application modes . 24
6 Interrupt processing .. 25
7 Event mechanism.. 27
8 Resource management .. 29
8.1 Behaviour during access to occupied resources. 29
8.2 Restrictions when using resources . 29
8.3 Scheduler as a resource .. 30
8.4 General problems with synchronisation mechanisms .. 30
8.4.1 Explanation of priority inversion.. 30
8.4.2 Deadlocks.. 31
8.5 OSEK Priority Ceiling Protocol. 31
8.6 OSEK Priority Ceiling Protocol with extensions for interrupt levels .. 32
8.7 Internal Resources 
9 Alarms
9.1 Counters
9.2 Alarm management 
9.3 Alarm-callback routines
10 Messages .38
11 Error handling, tracing and debugging
11.1 Hook routines
11.2 Error handling
11.3 System start-up 
11.4 System shutdown
11.5 Debugging
12 Description of system services
12.1 Definition of system objects 
12.2 Conventions ..44
12.2.1 Type of calls ..44
12.2.2 Legitimacy of calls ..44
12.2.3 Error characteristics.46
13 Specification of operating system services .48
13.1 Common data types ..48
13.2 Task management .49
13.2.1 Data types..49
13.2.2 Constructional elements ..50
13.2.3 System services .50
13.2.4 Constants .54
13.2.5 Naming convention .54
13.3 Interrupt handling .54
13.3.1 Data types..54
13.3.2 System services .54
13.3.3 Naming convention .57
13.4 Resource management ..58
13.4.1 Data types..58
13.4.2 Constructional elements ..58
13.4.3 System services .58
13.4.4 Constants .59
13.5 Event control.60
13.5.1 Data types..60
13.5.2 Constructional elements ..60
13.5.3 System services .60
13.6 Alarms.62
13.6.1 Data types..62
13.6.2 Constructional elements ..62
13.6.3 System services .63
13.6.4 Constants .65
13.6.5 Naming convention .66
13.7 Operating system execution control .66
13.7.1 Data types..66
13.7.2 System services .66
13.7.3 Constants .67
13.8 Hook routines..68
13.8.1 Data Types.68
13.8.2 System services .68
13.8.3 Constants. 69
13.8.4 Macros .. 69
14 Implementation and application specific topics.. 70
14.1 Implementation hints.. 70
14.1.1 Aspects of implementation . 70
14.1.2 Parameters of implementation .. 70
14.2 Application design hints. 72
14.2.1 Resource management .. 72
14.2.2 Placement of API calls.. 73
14.2.3 Interrupt service routines .. 73
14.2.4 Priority and preemption .. 74
14.2.5 Examples of usage of internal Resources . 75
14.2.6 Parameter to pass to ShutdownOS.. 75
14.2.7 Error handling . 75
14.2.8 Errors and warnings .. 76
14.3 Implementation specific tools .. 77
15 Changes from specification 1.0 to 2.2 .. 78
15.1 Changes from specification 1.0 to 2.0r1. 78
15.1.1 Conceptual changes .. 78
15.1.2 Clarifications. 79
15.1.3 Changes of the documentation.. 80
15.2 Changes from specification 2.0r1 to 2.1 and 2.1r1 .. 80
15.2.1 Behaviour of ChainTask/TerminateTask with allocated resources is
undefined. 80
15.2.2 GetTaskID is allowed in ISRs. . 80
15.2.3 Interrupt handling has been clarified and extended.. 81
15.2.4 Error checking of GetResource/ReleaseResource have been modified.. 81
15.2.5 Added constant OSTICKSPERBASE. . 81
15.2.6 ShutdownOS is allowed in ISRs and certain hook routines. .. 81
15.2.7 Behaviour of ShutdownOS after ShutdownHook returns is
implementation defined. . 81
15.2.8 Added constant OSDEFAULTAPPMODE. . 81
15.2.9 ErrorHook is never called recursively. . 81
15.2.10 Local Messages added to specification. 81
15.2.11 Startup/shutdown when OSEK and OSEKtime coexist (2.1r1) . 81
15.3 Changes from specification 2.1r1 to 2.2/2.2.1 (ISO version) .. 81
15.3.1 Add alarm-callbacks to alarms . 82
15.3.2 Interrupt handling: changes to functionality. 82
15.3.3 Scheduling: add internal resources . 82
15.3.4 Error handling . 82
15.3.5 Miscellaneous . 82
16 Index . 83
16.1 List of figures . 84
17 History .

改定案
>Table of Contents
1 Introduction
1.1 System philosophy 
1.2 Purpose of this document 
1.3 Structure of this document 
2 Summary
3 Interrupt processing 
3.1 Abstruction of ISR(Interrupt Service Routine)
3.2 Without OS ISR
3.3 With OS ISR
3.4 AUTOSAR timing protection ISR
4 Architecture of the OSEK operating system. 
4.1 Processing levels 
4.2 Conformance classes 
4.3 Relationship between OSEK OS and OSEKtime OS 
5 Error handling, tracing and debuggin
5.1 Hook routines
5.2 Error handling
5.3 System start-up 
5.4 System shutdown 
5.5 Debugging
6 Alarms
6.1 Counters
6.2 Alarm management 
6.3 Alarm-callback routines
7 Resource management 
7.1 Behaviour during access to occupied resources
7.2 Restrictions when using resources 
7.3 Scheduler as a resource 
7.4 General problems with synchronisation mechanisms 
7.4.1 Explanation of priority inversion
7.4.2 Deadlocks
7.5 OSEK Priority Ceiling Protocol
7.6 OSEK Priority Ceiling Protocol with extensions for interrupt levels 
7.7 Internal Resources 
8 Event mechanism.. 27
9 Task management . 16
9.1 Task concept. 16
9.2 Task state model. 16
9.2.1 Basic tasks
9.2.2 Extended tasks 
9.2.3 Comparison of the task types
9.3 Activating a task
9.4 Task switching mechanism
9.5 Task priority 
9.6 Scheduling policy
9.6.1 Full preemptive scheduling
9.6.2 Non preemptive scheduling 
9.6.3 Groups of tasks 
9.6.4 Mixed preemptive scheduling
9.6.5 Selecting the scheduling policy .. 23
9.7 Termination of tasks. 23
10 Application modes .. 24
10.1 Scope of application modes.. 24
10.2 Start up performance .. 24
10.3 Support for application modes . 24
11 Messages .38
12 Description of system services..44
12.1 Definition of system objects .44
12.2 Conventions ..44
12.2.1 Type of calls ..44
12.2.2 Legitimacy of calls ..44
12.2.3 Error characteristics.46
13 Specification of operating system services .48
13.1 Common data types ..48
13.2 Task management .49
13.2.1 Data types..49
13.2.2 Constructional elements ..50
13.2.3 System services .50
13.2.4 Constants .54
13.2.5 Naming convention .54
13.3 Interrupt handling .54
13.3.1 Data types..54
13.3.2 System services .54
13.3.3 Naming convention .57
13.4 Resource management ..58
13.4.1 Data types..58
13.4.2 Constructional elements ..58
13.4.3 System services .58
13.4.4 Constants .59
13.5 Event control.60
13.5.1 Data types..60
13.5.2 Constructional elements ..60
13.5.3 System services .60
13.6 Alarms.62
13.6.1 Data types..62
13.6.2 Constructional elements ..62
13.6.3 System services .63
13.6.4 Constants .65
13.6.5 Naming convention .66
13.7 Operating system execution control .66
13.7.1 Data types..66
13.7.2 System services .66
13.7.3 Constants .67
13.8 Hook routines..68
13.8.1 Data Types.68
13.8.2 System services .68
13.8.3 Constants. 69
13.8.4 Macros .. 69
14 Implementation and application specific topics.. 70
14.1 Implementation hints.. 70
14.1.1 Aspects of implementation . 70
14.1.2 Parameters of implementation .. 70
14.2 Application design hints. 72
14.2.1 Resource management .. 72
14.2.2 Placement of API calls.. 73
14.2.3 Interrupt service routines .. 73
14.2.4 Priority and preemption .. 74
14.2.5 Examples of usage of internal Resources . 75
14.2.6 Parameter to pass to ShutdownOS.. 75
14.2.7 Error handling . 75
14.2.8 Errors and warnings .. 76
14.3 Implementation specific tools .. 77
15 Changes from specification 1.0 to 2.2 .. 78
15.1 Changes from specification 1.0 to 2.0r1. 78
15.1.1 Conceptual changes .. 78
15.1.2 Clarifications. 79
15.1.3 Changes of the documentation.. 80
15.2 Changes from specification 2.0r1 to 2.1 and 2.1r1 .. 80
15.2.1 Behaviour of ChainTask/TerminateTask with allocated resources is
undefined. 80
15.2.2 GetTaskID is allowed in ISRs. . 80
15.2.3 Interrupt handling has been clarified and extended.. 81
15.2.4 Error checking of GetResource/ReleaseResource have been modified.. 81
15.2.5 Added constant OSTICKSPERBASE. . 81
15.2.6 ShutdownOS is allowed in ISRs and certain hook routines. .. 81
15.2.7 Behaviour of ShutdownOS after ShutdownHook returns is
implementation defined. . 81
15.2.8 Added constant OSDEFAULTAPPMODE. . 81
15.2.9 ErrorHook is never called recursively. . 81
15.2.10 Local Messages added to specification. 81
15.2.11 Startup/shutdown when OSEK and OSEKtime coexist (2.1r1) . 81
15.3 Changes from specification 2.1r1 to 2.2/2.2.1 (ISO version) .. 81
15.3.1 Add alarm-callbacks to alarms . 82
15.3.2 Interrupt handling: changes to functionality. 82
15.3.3 Scheduling: add internal resources . 82
15.3.4 Error handling . 82
15.3.5 Miscellaneous . 82
16 Index . 83
16.1 List of figures . 84
17 History 
Table of Contents
1 Introduction. 1
1.1 System philosophy . 6
1.2 Purpose of this document . 8
1.3 Structure of this document . 9
2 Summary. 11
3 Architecture of the OSEK operating system. 12
3.1 Processing levels .. 12
3.2 Conformance classes .. 13
3.3 Relationship between OSEK OS and OSEKtime OS .. 15
4 Task management . 16
4.1 Task concept. 16
4.2 Task state model. 16
4.2.1 Extended tasks .. 16
4.2.2 Basic tasks. 18
4.2.3 Comparison of the task types.. 18
4.3 Activating a task. 19
4.4 Task switching mechanism .. 19
4.5 Task priority . 19
4.6 Scheduling policy. 20
4.6.1 Full preemptive scheduling. 20
4.6.2 Non preemptive scheduling .. 21
4.6.3 Groups of tasks . 22
4.6.4 Mixed preemptive scheduling. 23
4.6.5 Selecting the scheduling policy .. 23
4.7 Termination of tasks. 23
5 Application modes .. 24
5.1 Scope of application modes.. 24
5.2 Start up performance .. 24
5.3 Support for application modes . 24
6 Interrupt processing .. 25
7 Event mechanism.. 27
8 Resource management .. 29
8.1 Behaviour during access to occupied resources. 29
8.2 Restrictions when using resources . 29
8.3 Scheduler as a resource .. 30
8.4 General problems with synchronisation mechanisms .. 30
8.4.1 Explanation of priority inversion.. 30
8.4.2 Deadlocks.. 31
8.5 OSEK Priority Ceiling Protocol. 31
8.6 OSEK Priority Ceiling Protocol with extensions for interrupt levels .. 32
8.7 Internal Resources .. 34
9 Alarms. 36
9.1 Counters.. 36
9.2 Alarm management .. 36
OSEK/VDX Operating System
Specification 2.2.3
4 © by OSEK OSEK OS 2.2.3
9.3 Alarm-callback routines..37
10 Messages .38
11 Error handling, tracing and debugging..39
11.1 Hook routines..39
11.2 Error handling.39
11.3 System start-up .41
11.4 System shutdown ..43
11.5 Debugging.43
12 Description of system services..44
12.1 Definition of system objects .44
12.2 Conventions ..44
12.2.1 Type of calls ..44
12.2.2 Legitimacy of calls ..44
12.2.3 Error characteristics.46
13 Specification of operating system services .48
13.1 Common data types ..48
13.2 Task management .49
13.2.1 Data types..49
13.2.2 Constructional elements ..50
13.2.3 System services .50
13.2.4 Constants .54
13.2.5 Naming convention .54
13.3 Interrupt handling .54
13.3.1 Data types..54
13.3.2 System services .54
13.3.3 Naming convention .57
13.4 Resource management ..58
13.4.1 Data types..58
13.4.2 Constructional elements ..58
13.4.3 System services .58
13.4.4 Constants .59
13.5 Event control.60
13.5.1 Data types..60
13.5.2 Constructional elements ..60
13.5.3 System services .60
13.6 Alarms.62
13.6.1 Data types..62
13.6.2 Constructional elements ..62
13.6.3 System services .63
13.6.4 Constants .65
13.6.5 Naming convention .66
13.7 Operating system execution control .66
13.7.1 Data types..66
13.7.2 System services .66
13.7.3 Constants .67
13.8 Hook routines..68
13.8.1 Data Types.68
13.8.2 System services .68
OSEK/VDX Operating System
Specification 2.2.3
OSEK OS 2.2.3 © by OSEK 5
13.8.3 Constants. 69
13.8.4 Macros .. 69
14 Implementation and application specific topics.. 70
14.1 Implementation hints.. 70
14.1.1 Aspects of implementation . 70
14.1.2 Parameters of implementation .. 70
14.2 Application design hints. 72
14.2.1 Resource management .. 72
14.2.2 Placement of API calls.. 73
14.2.3 Interrupt service routines .. 73
14.2.4 Priority and preemption .. 74
14.2.5 Examples of usage of internal Resources . 75
14.2.6 Parameter to pass to ShutdownOS.. 75
14.2.7 Error handling . 75
14.2.8 Errors and warnings .. 76
14.3 Implementation specific tools .. 77
15 Changes from specification 1.0 to 2.2 .. 78
15.1 Changes from specification 1.0 to 2.0r1. 78
15.1.1 Conceptual changes .. 78
15.1.2 Clarifications. 79
15.1.3 Changes of the documentation.. 80
15.2 Changes from specification 2.0r1 to 2.1 and 2.1r1 .. 80
15.2.1 Behaviour of ChainTask/TerminateTask with allocated resources is
undefined. 80
15.2.2 GetTaskID is allowed in ISRs. . 80
15.2.3 Interrupt handling has been clarified and extended.. 81
15.2.4 Error checking of GetResource/ReleaseResource have been modified.. 81
15.2.5 Added constant OSTICKSPERBASE. . 81
15.2.6 ShutdownOS is allowed in ISRs and certain hook routines. .. 81
15.2.7 Behaviour of ShutdownOS after ShutdownHook returns is
implementation defined. . 81
15.2.8 Added constant OSDEFAULTAPPMODE. . 81
15.2.9 ErrorHook is never called recursively. . 81
15.2.10 Local Messages added to specification. 81
15.2.11 Startup/shutdown when OSEK and OSEKtime coexist (2.1r1) . 81
15.3 Changes from specification 2.1r1 to 2.2/2.2.1 (ISO version) .. 81
15.3.1 Add alarm-callbacks to alarms . 82
15.3.2 Interrupt handling: changes to functionality. 82
15.3.3 Scheduling: add internal resources . 82
15.3.4 Error handling . 82
15.3.5 Miscellaneous . 82
16 Index . 83
16.1 List of figures . 84
17 History .