Embedded & Real-time Operating Systems Peter Marwedel TU Dortmund, Informatik 12 Germany Graphics: © Alexandra Nolte, Gesine Marwedel, 2003 These slides.

Slides:



Advertisements
Similar presentations
Fakultät für informatik informatik 12 technische universität dortmund Resource Access Protocols Peter Marwedel Informatik 12 TU Dortmund Germany 2008/12/06.
Advertisements

Fakultät für informatik informatik 12 technische universität dortmund Specifications and Modeling Peter Marwedel TU Dortmund, Informatik 12 Graphics: ©
Technische universität dortmund fakultät für informatik informatik 12 Specifications and Modeling Peter Marwedel TU Dortmund, Informatik
Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
Priority Inheritance and Priority Ceiling Protocols
Introduction to Embedded Systems Resource Management - III Lecture 19.
Priority INHERITANCE PROTOCOLS
Part IV: Memory Management
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING.
Hardware/ Software Partitioning 2011 年 12 月 09 日 Peter Marwedel TU Dortmund, Informatik 12 Germany Graphics: © Alexandra Nolte, Gesine Marwedel, 2003 These.
1 EE5900 Advanced Embedded System For Smart Infrastructure RMS and EDF Scheduling.
CS5270 Lecture 31 Uppaal, and Scheduling, and Resource Access Protocols CS 5270 Lecture 3.
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Resource Access Control Protocols.
Mutual Exclusion.
Real-Time Kernels and Operating Systems Basic Issue - Purchase commercial “off-the- shelf” system or custom build one Basic Functions –Task scheduling.
Chapter 13 Embedded Systems
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
UCDavis, ecs150 Fall /23/2007ecs150, fall Operating System ecs150 Fall 2007 : Operating System #3: Priority Inversion (a paper on the class.
UCDavis, ecs150 Spring /21/2006ecs150, spring Operating System ecs150 Spring 2006 : Operating System #3: Priority Inversion (paper) Dr. S.
Chapter 13 Embedded Systems
OS Spring’03 Introduction Operating Systems Spring 2003.
Figure 1.1 Interaction between applications and the operating system.
CS533 - Concepts of Operating Systems
CprE 458/558: Real-Time Systems
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
UCDavis, ecs251 Fall /23/2007ecs251, fall Operating System Models ecs251 Fall 2007 : Operating System Models #3: Priority Inversion Dr. S.
Copyright Arshi Khan1 System Programming Instructor Arshi Khan.
Performance Evaluation of Real-Time Operating Systems
CS4101 嵌入式系統概論 RTOS and MQX Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from Freescale; Prof.
Introduction to Embedded Systems
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
Real Time Operating Systems Lecture 10 David Andrews
Real-Time Systems Design1 Priority Inversion When a low-priority task blocks a higher-priority one, a priority inversion is said to occur Assume that priorities:
Scheduling policies for real- time embedded systems.
Real-Time Operating Systems for Embedded Computing 李姿宜 R ,06,10.
Chapter 101 Multiprocessor and Real- Time Scheduling Chapter 10.
Universität Dortmund Technische Universität Dortmund Embedded & Real-time Operating Systems Peter Marwedel TU Dortmund, Germany.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Embedded & Real-time Operating Systems Peter Marwedel TU Dortmund, Informatik 12 Germany 2012 年 11 月 27 日 These slides use Microsoft clip arts. Microsoft.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Deadlocks Silberschatz Ch. 7 and Priority Inversion Problems.
Deadlock Detection and Recovery
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 2006 Universität Dortmund Periodic scheduling For periodic scheduling, the best that we can do is to.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Introduction to Embedded Systems Rabie A. Ramadan 5.
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 05/06 Universität Dortmund Embedded operating systems - Requirement: Configurability - Configurability.
Lab 4 : Real-Time OS Team #7 P 李彥勳 P 謝嵩淮 R 侯凱文.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Real-Time Operating Systems RTOS For Embedded systems.
Introduction to Real-Time Operating Systems
REAL-TIME OPERATING SYSTEMS
RTOS Scheduling 2.0 Problems - Solutions
Scheduling and Resource Access Protocols: Basic Aspects
Real-time Software Design
Embedded & Real-time Operating Systems
CS4101 嵌入式系統概論 RTOS Prof. Chung-Ta King Department of Computer Science
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Threads Chapter 4.
Chapter 2: Operating-System Structures
Foundations and Definitions
Real-Time Process Scheduling Concepts, Design and Implementations
Chapter 2: Operating-System Structures
COMP755 Advanced Operating Systems
Real-Time Process Scheduling Concepts, Design and Implementations
Presentation transcript:

Embedded & Real-time Operating Systems Peter Marwedel TU Dortmund, Informatik 12 Germany Graphics: © Alexandra Nolte, Gesine Marwedel, 2003 These slides use Microsoft clip arts. Microsoft copyright restrictions apply 年 12 月 17 日

- 2 -  p. marwedel, informatik 12, 2011 Structure of this course 2: Specification 3: ES-hardware 4: system software (RTOS, middleware, …) 8: Test 5: Evaluation & validation (energy, cost, performance, …) 7: Optimization 6: Application mapping Application Knowledge Design repository Design Numbers denote sequence of chapters

- 3 -  p. marwedel, informatik 12, 2011 Reuse of standard software components Knowledge from previous designs to be made available in the form of intellectual property (IP, for SW & HW).  Operating systems  Middleware  ….

- 4 -  p. marwedel, informatik 12, 2011 Embedded operating systems - Characteristics: Configurability - Configurability No single OS will fit all needs, no overhead for unused functions tolerated  configurability needed.  Simplest form: remove unused functions (by linker ?).  Conditional compilation (using #if and #ifdef commands).  Dynamic data might be replaced by static data.  Advanced compile-time evaluation useful.  Object-orientation could lead to a derivation subclasses.

- 5 -  p. marwedel, informatik 12, 2011 Example: Configuration of VxWorks © Windriver /tornado_2_ds.pdf

- 6 -  p. marwedel, informatik 12, 2011 Verification of derived OS? Verification a potential problem of systems with a large number of derived OSs:  Each derived OS must be tested thoroughly;  Potential problem for eCos (open source RTOS from Red Hat), including 100 to 200 configuration points [Takada, 01].

- 7 -  p. marwedel, informatik 12, 2011 Embedded operating systems - Disc and network handled by tasks -  Effectively no device that needs to be supported by all variants of the OS, except maybe the system timer.  Many ES without disc, a keyboard, a screen or a mouse.  Disc & network handled by tasks instead of integrated drivers. Discs & networks can be handled by tasks. Embedded OSStandard OS kernel

- 8 -  p. marwedel, informatik 12, 2011 Example: WindRiver Platform Industrial Automation © Windriver

- 9 -  p. marwedel, informatik 12, 2011 Embedded operating systems - Protection is optional- Protection mechanisms not always necessary: ES typically designed for a single purpose, untested programs rarely loaded, SW considered reliable. Privileged I/O instructions not necessary and tasks can do their own I/O. Example: Let switch be the address of some switch Simply use load register,switch instead of OS call. However, protection mechanisms may be needed for safety and security reasons.

 p. marwedel, informatik 12, 2011 Embedded operating systems - Interrupts not restricted to OS - Interrupts can be employed by any process For standard OS: serious source of unreliability. Since  embedded programs can be considered to be tested,  since protection is not necessary and  since efficient control over a variety of devices is required,  it is possible to let interrupts directly start or stop tasks (by storing the task’s start address in the interrupt table).  More efficient than going through OS services.  Reduced composability: if a task is connected to an interrupt, it may be difficult to add another task which also needs to be started by an event.

 p. marwedel, informatik 12, 2011 Embedded operating systems - Real-time capability- Many embedded systems are real-time (RT) systems and, hence, the OS used in these systems must be real-time operating systems (RTOSs).

 p. marwedel, informatik 12, 2011 RT operating systems - Definition and requirement 1: predictability - Def.: (A) real-time operating system is an operating system that supports the construction of real-time systems. The following are the three key requirements 1.The timing behavior of the OS must be predictable.  services of the OS: Upper bound on the execution time! RTOSs must be timing-predictable:  short times during which interrupts are disabled,  (for hard disks:) contiguous files to avoid unpredictable head movements. [Takada, 2001]

 p. marwedel, informatik 12, 2011 Real-time operating systems Requirement 2: Managing timing 2.OS should manage the timing and scheduling  OS possibly has to be aware of task deadlines; (unless scheduling is done off-line).  Frequently, the OS should provide precise time services with high resolution. [Takada, 2001]

 p. marwedel, informatik 12, 2011 Time services Time plays a central role in “real-time” systems. Actual time is described by real numbers. Two discrete standards are used in real-time equipment:  International atomic time TAI (french: temps atomic internationale) Free of any artificial artifacts.  Universal Time Coordinated (UTC) UTC is defined by astronomical standards UTC and TAI identical on Jan. 1st, seconds had to be added since then. Not without problems: New Year may start twice per night.

 p. marwedel, informatik 12, 2011 Internal synchronization  Synchronization with one master clock Typically used in startup-phases  Distributed synchronization: 1.Collect information from neighbors 2.Compute correction value 3.Set correction value. Precision of step 1 depends on how information is collected: Application level: ~500 µs to 5 ms Operation system kernel: 10 µs to 100 µs Communication hardware: < 10 µs

 p. marwedel, informatik 12, 2011 External synchronization External synchronization guarantees consistency with actual physical time. Trend is to use GPS for ext. synchronization GPS offers TAI and UTC time information. Resolution is about 100 ns. © Dell GPS mouse

 p. marwedel, informatik 12, 2011 Problems with external synchronization Problematic from the perspective of fault tolerance: Erroneous values are copied to all stations. Consequence: Accepting only small changes to local time. Many time formats too restricted; e.g.: NTP protocol includes only years up to 2036 For time services and global synchronization of clocks synchronization see Kopetz, 1997.

 p. marwedel, informatik 12, 2011 Real-time operating systems Requirement 3: Speed 3.The OS must be fast Practically important. [Takada, 2001]

 p. marwedel, informatik 12, 2011 RTOS-Kernels Distinction between  real-time kernels and modified kernels of standard OSes. Distinction between  general RTOSs and RTOSs for specific domains,  standard APIs (e.g. POSIX RT-Extension of Unix, ITRON, OSEK) or proprietary APIs.

 p. marwedel, informatik 12, 2011 Functionality of RTOS-Kernels Includes  processor management,  memory management,  and timer management;  task management (resume, wait etc),  inter-task communication and synchronization. resource management

 p. marwedel, informatik 12, 2011 Classes of RTOSes according to R. Gupta: 1. Fast proprietary kernels For complex systems, these kernels are inadequate, because they are designed to be fast, rather than to be predictable in every respect [R. Gupta, UCI/UCSD] Examples include QNX, PDOS, VCOS, VTRX32, VxWORKS.

 p. marwedel, informatik 12, 2011 Classes of RTOSs according to R. Gupta: 2. RT extensions to std. OSs Attempt to exploit comfortable main stream OS. RT-kernel running all RT-tasks. Standard-OS executed as one task. + Crash of standard-OS does not affect RT-tasks; - RT-tasks cannot use Standard-OS services; less comfortable than expected

 p. marwedel, informatik 12, 2011 Example: RT-Linux RT-tasks cannot use standard OS calls. Commercially available from fsmlabs ( Hardware RT-Task RT-Linux RT-Scheduler Linux-Kernel driver scheduler Init BashMozilla interrupts I/O

 p. marwedel, informatik 12, 2011 Example: Posix 1.b RT-extensions to Linux Standard scheduler can be replaced by POSIX scheduler implementing priorities for RT tasks Hardware Linux-Kernel driver POSIX 1.b scheduler Init BashMozilla I/O, interrupts RT-Task Special RT-calls and standard OS calls available. Easy programming, no guarantee for meeting deadline Special RT-calls and standard OS calls available. Easy programming, no guarantee for meeting deadline

 p. marwedel, informatik 12, 2011 Evaluation (Gupta) According to Gupta, trying to use a version of a standard OS: not the correct approach because too many basic and inappropriate underlying assumptions still exist such as optimizing for the average case (rather than the worst case),... ignoring most if not all semantic information, and independent CPU scheduling and resource allocation. Dependences between tasks not frequent for most applications of std. OSs & therefore frequently ignored. Situation different for ES since dependences between tasks are quite common.

 p. marwedel, informatik 12, 2011 Classes of RTOSs (R. Gupta): 3. Research trying to avoid limitations Research systems trying to avoid limitations. Include MARS, Spring, MARUTI, Arts, Hartos, DARK, and Melody Research issues [Takada, 2001]:  low overhead memory protection,  temporal protection of computing resources  RTOSes for on-chip multiprocessors  support for continuous media  quality of service (QoS) control.

Resource Access Protocols Peter Marwedel Informatik 12 TU Dortmund Germany Graphics: © Alexandra Nolte, Gesine Marwedel, 2003

 p. marwedel, informatik 12, 2011 Resource access protocols Critical sections: sections of code at which exclusive access to some resource must be guaranteed. Can be guaranteed with semaphores S or “mutexes”. P(S) V(S) P(S) V(S) P(S) checks semaphore to see if resource is available and if yes, sets S to “used“. Uninterruptible operations! If no, calling task has to wait. V(S): sets S to “unused“ and starts sleeping task (if any). P(S) checks semaphore to see if resource is available and if yes, sets S to “used“. Uninterruptible operations! If no, calling task has to wait. V(S): sets S to “unused“ and starts sleeping task (if any). Mutually exclusive access to resource guarded by S Task 1 Task 2

 p. marwedel, informatik 12, 2011 Blocking due to mutual exclusion Priority T 1 assumed to be > than priority of T 2. If T 2 requests exclusive access first (at t 0 ), T 1 has to wait until T 2 releases the resource (time t 3 ), thus inverting the priority: In this example: blocking is bounded by length of critical section of T 2.

 p. marwedel, informatik 12, 2011 Blocking with >2 tasks can exceed the length of any critical section Priority of T 1 > priority of T 2 > priority of T 3. T 2 preempts T 3 : T 2 can prevent T 3 from releasing the resource. Priority inversion!

 p. marwedel, informatik 12, 2011

 p. marwedel, informatik 12, 2011 The MARS Pathfinder problem (1) “But a few days into the mission, not long after Pathfinder started gathering meteorological data, the spacecraft began experiencing total system resets, each resulting in losses of data. The press reported these failures in terms such as "software glitches" and "the computer was trying to do too many things at once".” …

 p. marwedel, informatik 12, 2011 The MARS Pathfinder problem (2) “VxWorks provides preemptive priority scheduling of threads. Tasks on the Pathfinder spacecraft were executed as threads with priorities that were assigned in the usual manner reflecting the relative urgency of these tasks.” “Pathfinder contained an "information bus", which you can think of as a shared memory area used for passing information between different components of the spacecraft.”  A bus management task ran frequently with high priority to move certain kinds of data in and out of the information bus. Access to the bus was synchronized with mutual exclusion locks (mutexes).”

 p. marwedel, informatik 12, 2011 The MARS Pathfinder problem (3)  The meteorological data gathering task ran as an infrequent, low priority thread, … When publishing its data, it would acquire a mutex, do writes to the bus, and release the mutex...  The spacecraft also contained a communications task that ran with medium priority.”  High priority: retrieval of data from shared memory Medium priority: communications task Low priority: thread collecting meteorological data

 p. marwedel, informatik 12, 2011 The MARS Pathfinder problem (4) “Most of the time this combination worked fine. However, very infrequently it was possible for an interrupt to occur that caused the (medium priority) communications task to be scheduled during the short interval while the (high priority) information bus thread was blocked waiting for the (low priority) meteorological data thread. In this case, the long-running communications task, having higher priority than the meteorological task, would prevent it from running, consequently preventing the blocked information bus task from running. After some time had passed, a watchdog timer would go off, notice that the data bus task had not been executed for some time, conclude that something had gone drastically wrong, and initiate a total system reset. This scenario is a classic case of priority inversion.” ars_Pathfinder/Mars_Pathfinder.html

 p. marwedel, informatik 12, 2011 Coping with priority inversion: the priority inheritance protocol  Tasks are scheduled according to their active priorities. Tasks with the same priorities are scheduled FCFS.  If task T 1 executes P(S) & exclusive access granted to T 2 : T 1 will become blocked. If priority( T 2 ) < priority( T 1 ): T 2 inherits the priority of T 1.  T 2 resumes. Rule: tasks inherit the highest priority of tasks blocked by it.  When T 2 executes V(S), its priority is decreased to the highest priority of the tasks blocked by it. If no other task blocked by T 2 : priority( T 2 ):= original value. Highest priority task so far blocked on S is resumed.  Transitive: if T 2 blocks T 1 and T 1 blocks T 0, then T 2 inherits the priority of T 0.

 p. marwedel, informatik 12, 2011 Example T 3 inherits the priority of T 1 and T 3 resumes. How would priority inheritance affect our example with 3 tasks? leviRTS animation

 p. marwedel, informatik 12, 2011 Nested critical sections

 p. marwedel, informatik 12, 2011 Transitiveness of priority inheritance [P/V

 p. marwedel, informatik 12, 2011

 p. marwedel, informatik 12, 2011 Priority inversion on Mars Priority inheritance also solved the Mars Pathfinder problem: the VxWorks operating system used in the pathfinder implements a flag for the calls to mutex primitives. This flag allows priority inheritance to be set to “on”. When the software was shipped, it was set to “off”. The problem on Mars was corrected by using the debugging facilities of VxWorks to change the flag to “on”, while the Pathfinder was already on the Mars [Jones, 1997].

 p. marwedel, informatik 12, 2011 Remarks on priority inheritance protocol Possible large number of tasks with high priority. Possible deadlocks. Ongoing debate about problems with the protocol: Victor Yodaiken: Against Priority Inheritance, Sept. 2004, Finds application in ADA: During rendez-vous, task priority is set to the maximum. Protocol for fixed set of tasks: priority ceiling protocol.

 p. marwedel, informatik 12, 2011 Summary  General requirements for embedded operating systems Configurability I/O Interrupts  General properties of real-time operating systems Predictability Time services Synchronization Classes of RTOSs, Device driver embedding  Priority inversion The problem Priority inheritance

 p. marwedel, informatik 12, 2011 SPARES

 p. marwedel, informatik 12, 2011 Byzantine Error Erroneous local clocks can have an impact on the computed local time. Advanced algorithms are fault-tolerant with respect to Byzantine errors. Excluding k erroneous clocks is possible with 3 k +1 clocks (largest and smallest values will be excluded. Many publications in this area. t k =1

 p. marwedel, informatik 12, 2011 Virtual machines  Emulate several processors on a single real processor  Running As Single process (Java virtual machine) On bare hardware Allows several operating systems to be executed on top Very good shielding between applications  Temporal behavior?