Professional Documents
Culture Documents
Introduction to
OSEK/VDX
Course #25516
IntroToRTOSandOSEK_Module1.ppt;1 31 March, 2006
and
Copyright 2003-2006 Delphi Technologies, Inc. All rights reserved. Introduction to RTOS / OSEK Module 1
EX CELLEN CE
Focus:
Your Customer
Control:
Customer Feedback
Performance Goal:
Do It Right The First Time, Every Time
People:
Caring
Method:
Innovation & Continuous Improvement
Style:
Teamwork
Reward:
Recognition & Security
-3Delphi Software Global College
Class Overview
Description
This course is an introduction and/or refresher for engineers in the Software competency. The course will cover real-time operating systems concepts and the differences between an RTOS and a cyclical executive. The course will also provide an overview of the OSEK/VDX standard for automotive real-time operating systems and discuss issues involved in using OSEK. Finally, the class will cover current RTOS and OSEK related activities at Delphi. The purpose of this course is to provide a basic introduction to real-time operating systems, and to OSEK/VDX - a set of standards for real-time operating systems designed for use in automotive systems.
Audience
This course is intended for Software or Systems Engineers needing an introduction to RTOS concepts or an overview of the OSEK/VDX operating system standards.
Class Objectives
Be familiar with RTOS concepts such as tasks ISRs priorities scheduling synchronization
Understand the basic concepts behind the OSEK/VDX standards. Know about how using an RTOS affects some system design issues.
Be aware of RTOS- and OSEK-related activities at Delphi, and know where to find more information.
Course Outline
Module 1
Class Information & Introductions Introduction to Real-Time Operating Systems Real-Time Operating System Concepts
Module 2
Overview of OSEK/VDX The OSEK/VDX Project OSEK OS OSEK OIL OSEK COM OSEK NM
Module 3
RTOS System Architecture Issues RTOS and OSEK Activities at Delphi Summary
Refer to the Glossary at the end of Module 3 of this training material for definitions of acronyms, abbreviations and other terms used. Most can also be found in the on-line dictionary
Course Outline
Class
Information & Introductions Introduction to Real-Time Operating Systems Real-Time Operating System Concepts Overview of OSEK/VDX
The OSEK/VDX Project OSEK OS OSEK OIL OSEK COM OSEK NM
RTOS
Section 1
Software that provides an intermediate layer between an application and the target hardware Provides a layer of abstraction between the application software and the computer hardware Operating System Responsibilities:
Manage and allocate computer resources (CPU, memory, devices, etc.) Control execution of application program(s) and operation of I/O devices Utilize the computer hardware in an efficient manner
Examples:
Time-Sharing / Single-User: OS/360 MVS MS-DOS MS-Windows Max OS-X UNIX LINUX VAX/VMS
Real-Time: ITRON LynxOS OS-9 QNX VxWorks VTRX MicroC/OS-II OSEK/VDX
Responsiveness
Overload
A Real-time System must provide a response to a given input, and must do it before a specified deadline
Event Response Deadline
Function
Latency
Processing Time
time
Introduction to RTOS / OSEK Module 1
- 11 Delphi Software Global College
0 ms
Source: LiveDevices Inc.
5 ms
10 ms
Introduction to RTOS / OSEK Module 1
15 ms
Ideal:
Ideally, the processor utilization of a periodic function can be calculated by dividing its processing time by its period. Example: If Function1 take 1 millisecond to execute, and runs every 5 milliseconds, it consumes 20% of the processor throughput.
Actual:
Simple cyclic scheduling may require that some tasks be run more frequently than would otherwise be necessary, in order to keep the scheduler simple. Those tasks therefore consume more throughput than the ideal case.
Period (Max.) 5 ms 10 ms 14 ms
Period (Actual) 5 ms 5 ms 5 ms
Function2 executed more often than required; uses 24% of throughput, instead of 12%. Function3 executed more often than required; uses 36% of throughput, instead of 13%. Overall, the system uses 80% of the throughput. Adding more functionality or an interrupt that uses 1.0 ms processing time makes the system fully loaded. (Even if interrupts are more than 5 ms apart.)
0 ms
Source: LiveDevices Inc.
Delphi Business Proprietary
5 ms
10 ms
Introduction to RTOS / OSEK Module 1
15 ms
- 14 Delphi Software Global College
Function3
14 ms
1.8 ms
Design: 10 ms major cycle, containing 5 ms minor cycles Function1 and Function2 run every minor cycle; Function3 runs every major cycle Time must be allocated for Interrupt 1 in every minor cycle (even though it will used less than half the time). Throughput: Better, but Function3 is still executed more often than required; it uses 18% of throughput, instead of 13%.
0 ms
Source: LiveDevices Inc.
Delphi Business Proprietary
5 ms
10 ms
Introduction to RTOS / OSEK Module 1
15 ms
- 15 Delphi Software Global College
Change:
Function2 reduced to 0.8 ms Function3 reduced to 1.2 ms New Function4 added.
There is sufficient throughput available, but Function4 must be artificially partitioned to make it fit.
0 ms
Source: LiveDevices Inc.
Delphi Business Proprietary
5 ms
10 ms
Introduction to RTOS / OSEK Module 1
15 ms
- 16 Delphi Software Global College
Advantages:
Simple in concept Predictable behaviour Minimal processing overhead
Disadvantages:
Design complicated by timing behaviour Inflexible Maintenance can be difficult Processor time is not used efficiently
priority
time
0 ms
5 ms
10 ms
15 ms
priority
0 ms
Source: LiveDevices Inc.
Delphi Business Proprietary
5 ms
Introduction to RTOS / OSEK Module 1
10 ms
15 ms
- 19 Delphi Software Global College
Maximizes CPU utilization Provides well-defined functionality and behavior Encapsulates scheduling independent of the application
Simplifies software system design Operating system becomes the interface (API), not the hardware Supports potential code generation Provides capability for software reuse / portability
Critical sections
Task synchronization and data coherency must be addressed If tasks share data, there is the possibility of incorrect data
Course Outline
Class
Information & Introductions Introduction to Real-Time Operating Systems Real-Time Operating System Concepts Overview of OSEK/VDX
The OSEK/VDX Project OSEK OS OSEK OIL OSEK COM OSEK NM
RTOS
Section 2
Tasks
A tasks context is how the RTOS perceives a task A context switch occurs when the RTOS decides to run a different task A Task Control Block (TCB) is a data structure used by the RTOS to manage each task The TCB stores a tasks context, and may contain
program counter status register stack pointer CPU registers task data
Task States
wait
running
terminate
waiting
preempt
start/ resume
suspended
release ready
activate
All tasks are initially in the suspended state.
Preemptive Scheduling
Preemptive
If a new task with a priority higher than the currently executing task becomes ready to run, then the operating system will preempt the current task and switch to the higher priority task
(Illustration Step 1 of 9)
CPU
SP PC MSR R0 R1 R2 R3
(Illustration Step 2 of 9)
Task1 Stack
CPU
SP PC MSR R0 R1 R2 R3
Func1B Data
Func1A Data
. . .
Task1 TCB SP
. . .
Func1B Code
(Illustration Step 3 of 9)
Task1 Stack Task2 Stack
CPU
SP PC MSR R0 R1 R2 R3
Func1B Data
Func1A Data
. . .
Task1 TCB SP
. . .
Task2 TCB SP
. . .
Func1B Code
. . .
Func2C Code
(Illustration Step 4 of 9)
Task1 Stack Task2 Stack
CPU
PC MSR Func1B Data SP PC MSR R0 R1 R2 R3
Func1A Data
. . .
Task1 TCB SP RTOS Code
. . .
Task2 TCB SP
. . .
Func1B Code
. . .
Func2C Code
The
(Illustration Step 5 of 9)
Task1 Stack Task2 Stack
CPU
SP PC MSR R0 R1 R2 R3
Func1A Data
. . .
Task1 TCB SP RTOS Code
. . .
Task2 TCB SP
. . .
Func1B Code
. . .
Func2C Code
(Illustration Step 6 of 9)
Task1 Stack Task2 Stack
CPU
SP PC MSR R0 R1 R2 R3
Func1A Data
. . .
Task1 TCB SP RTOS Code
. . .
Task2 TCB SP
. . .
Func1B Code
. . .
Func2C Code
The RTOS saves the stack pointer (SP) in Task1s TCB All of Task1s context is now saved
(Illustration Step 7 of 9)
Task1 Stack Task2 Stack
CPU
SP PC MSR R0 R1 R2 R3
Func1A Data
. . .
Task1 TCB SP RTOS Code
. . .
Task2 TCB SP
. . .
Func1B Code
. . .
Func2C Code
The RTOS sets the stack pointer (SP) to the value previously stored in Task2s TCB
(Illustration Step 8 of 9)
Task1 Stack Task2 Stack
CPU
SP PC MSR R0 R1 R2 R3
Func1A Data
. . .
Task1 TCB SP RTOS Code
. . .
Task2 TCB SP
. . .
Func1B Code
. . .
Func2C Code
The RTOS pops the general-purpose register values from Task2s stack
(Illustration Step 9 of 9)
Task1 Stack Task2 Stack
CPU
SP PC MSR R0 R1 R2 R3
Func1A Data
. . .
Task1 TCB SP RTOS Code
. . .
Task2 TCB SP
. . .
Func1B Code
. . .
Func2C Code
Task2 is now the current running task, and takes picking up where it was when it got suspended
control
Since a task can be preempted at any time, task code must be reentrant. Reentrant code is code designed to maintain data integrity even though the code can be interrupted at any point, and a parallel instance of code may be invoked. To be reentrant, code must
Use any shared variables in an atomic or protected way Access hardware resources in an atomic way Not call any non-reentrant functions
Task Synchronization
A shared resource is a resource that may be used by more than one task
For shared resources, task synchronization is required to prevent potential corruption of data
Schedulability Analysis
Period 5 ms (min) 10 ms (min) n+1 R 3 ms = Ci + i 6 ms 14 ms 14 ms
k hp(i) 6.0 ms
T
Processing Time 0.2 ms 0.5 ms 0.5 ms 0.6 ms 1.4 ms
Deadline -----
Rin
k
Ck
3 ms 6 ms
14 ms 14 ms
0 ms
Source: LiveDevices Inc.
Delphi Business Proprietary
5 ms
Introduction to RTOS / OSEK Module 1
10 ms
15 ms
- 39 Delphi Software Global College
Response
ISR1 ISR2 Task1 Task2 Task3 Task4 (Idle)
Deadline Response
0 ms
Delphi Business Proprietary
5 ms
Introduction to RTOS / OSEK Module 1
10 ms
15 ms
- 40 Delphi Software Global College
End of Module 1
Revision History
By M. Malone Description
Derived from revision 9 of the original training, now split into 3 modules.