ASQF Fachgruppe Automation/ Automation Day 1 Realtime capable Linux: Requirements (Standard)LinuxRealtime LinuxRealtime kernel One (physical) address space.

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
Model for Supporting High Integrity and Fault Tolerance Brian Dobbing, Aonix Europe Ltd Chief Technical Consultant.
ECE 526 – Network Processing Systems Design Software-based Protocol Processing Chapter 7: D. E. Comer.
Chapter 5 Processes and Threads Copyright © 2008.
Priority Inversion Higher priority task is blocked by a lower priority one. May be caused by semaphore usage, device conflicts, bad design of interrupt.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
INTRODUCTION OS/2 was initially designed to extend the capabilities of DOS by IBM and Microsoft Corporations. To create a single industry-standard operating.
1 Concurrent and Distributed Systems Introduction 8 lectures on concurrency control in centralised systems - interaction of components in main memory -
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
3.5 Interprocess Communication
Soft Timers: Efficient Microsecond Software Timer Support For Network Processing Mohit Aron and Peter Druschel Rice University Presented by Reinette Grobler.
Chapter 13 Embedded Systems
Figure 1.1 Interaction between applications and the operating system.
1 When to Switch Processes 3 triggers –System call, Interrupt and Trap System call –when a user program invokes a system call. e.g., a system call that.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
CS 3013 & CS 502 Summer 2006 Threads1 CS-3013 & CS-502 Summer 2006.
The Design of Robust and Efficient Microkernel ManRiX, The Design of Robust and Efficient Microkernel Presented by: Manish Regmi
Xen and the Art of Virtualization. Introduction  Challenges to build virtual machines Performance isolation  Scheduling priority  Memory demand  Network.
Operating Systems CSE 411 CPU Management Sept Lecture 11 Instructor: Bhuvan Urgaonkar.
SymCall: Symbiotic Virtualization Through VMM-to-Guest Upcalls John R. Lange and Peter Dinda University of Pittsburgh (CS) Northwestern University (EECS)
Presentation by Betsy Kavali
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.
LWIP TCP/IP Stack 김백규.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
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:
The Performance of Microkernel-Based Systems
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
The Performance of Micro-Kernel- Based Systems H. Haertig, M. Hohmuth, J. Liedtke, S. Schoenberg, J. Wolter Presentation by: Seungweon Park.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Threads G.Anuradha (Reference : William Stallings)
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
Real-Time, Clocking, and Porting (My Job ) Determining the Real Time Capabilities of various Operating Systems. Writing code to support Real Time Clocking.
Linux for Real Time applications in accelerator control systems Linux for control systems Andreas Steinbacher
Lecture 8 Page 1 CS 111 Online Other Important Synchronization Primitives Semaphores Mutexes Monitors.
The Performance of μ-Kernel-Based Systems H. Haertig, M. Hohmuth, J. Liedtke, S. Schoenberg, J. Wolter Presenter: Sunita Marathe.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks II.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
CS533 – Spring Jeanie M. Schwenk Experiences and Processes and Monitors with Mesa What is Mesa? “Mesa is a strongly typed, block structured programming.
The Performance of Micro-Kernel- Based Systems H. Haertig, M. Hohmuth, J. Liedtke, S. Schoenberg, J. Wolter Presentation by: Tim Hamilton.
Challenges in Porting & Abstraction. Getting Locked-In Applications are developed with a particular platform in mind The software is locked to the current.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Migrate a RTAI Application to RT- Preempt - A case study lin u troni x.
REAL-TIME OPERATING SYSTEMS
Introduction to the CVM and the Timesys RI
CS 6560: Operating Systems Design
The Mach System Sri Ramkrishna.
Topics Covered What is Real Time Operating System (RTOS)
Outline Other synchronization primitives
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Chapter 5: Threads Overview Multithreading Models Threading Issues
Other Important Synchronization Primitives
Chapter 6: CPU Scheduling
Chapter 3: Windows7 Part 2.
I/O Systems I/O Hardware Application I/O Interface
Chapter 3: Windows7 Part 2.
CPU SCHEDULING.
Architectural Support for OS
Supporting Time-Sensitive Applications on a Commodity OS
Architectural Support for OS
Chapter 3: Process Management
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

ASQF Fachgruppe Automation/ Automation Day 1 Realtime capable Linux: Requirements (Standard)LinuxRealtime LinuxRealtime kernel One (physical) address space with n-tasks Application program 100% source compatibility better binary compatibility API Response time: < 10 µsResponse time: ~1ms Response time: < 10 µs same homogeneity One process address space with n-threads All tasks have one common API implemented by one common library All threads of a process have one common API implemented by one common library

ASQF Fachgruppe Automation/ Automation Day 2 Realtime capable Linux: The important questions Is the POSIX-API suitable? –Only a subset is relevant for realtime applications –The mechanism for the notification of asynchronous events determine widespread usage Can it provide for competitive performance? –Ideally it should be as good as specialized realtime kernels –Ultimately cycle times of 31,25 µs should be possible What about additional changes to the Linux kernel ? –Ideally none –Only minimal changes allow for long time support

ASQF Fachgruppe Automation/ Automation Day 3 Thread management –Creation,Termination, Scheduling Synchronization –Mutex –Spinlock  Communication –POSIX Message Queue –Semaphore –Shared Memory  Timer – types (periodic, one shot, absolute, relative) – resolution – clock tick – notification The POSIX-API: Minimal set for realtime tasks needs improvements

ASQF Fachgruppe Automation/ Automation Day 4 The POSIX Notification-API: The Timer-API Timer sigevent object SIGEV_THREAD CLOCK_REALTIME SIGEV_SIGNAL SIGEV_NONE timer_create (clockid_t clockid, timer_t *timerid, struct sigevent *evp); Problems: SIGEV_THREAD: The implementation within the glibc is not realtime capable  another implementation fixes it (deterministic, performance improvement by a factor of 10) SIGEV_SIGNAL: Sending a signal to the entire process is not deterministic. Potentially the entire thread list of a process must be scanned.  minimal overhead and deterministic behavior require sending to a thread (Linux can handle it)  no response based on signal handlers (signal handlers are for synchronous exceptions only)  having explicit wait only allows for extremely fast notification.

ASQF Fachgruppe Automation/ Automation Day 5 SIGEV_THREAD: The realtime capable implementation sigwaitinfo() handler carrier thread signal to thread realtime implementation Solution: creation of carrier thread at timer creation Trade off between memory consumption and independent handlers controllable same pthread_attr object with same values  share an existing carrier thread different pthread_attr object or the same but with different values  create new carrier thread C ompletely deterministic Performance improvement more than a factor of 10 sigwaitinfo() signal to thread pthread_exit() handler pthread_create() carrier thread managing thread current glibc implementation pthread_exit() handler sigwaitinfo() handler carrier thread signal to thread

ASQF Fachgruppe Automation/ Automation Day 6 The POSIX Notification-API: Extensions(1) t timer fires sigwait() Scenario a sigwait() Scenario b timer overrun sigwait() Scenario c Can be queried This situation must get signalled An additional call sigevent_set_notification() makes sending the signal to a thread available at the API level. This call maps the threadid of the API to the tid of the kernel allows via an additional encoding of the sigev_notify field for supervision of timeliness implementation with best possible deterministic behavior The existing sigevent structure needs no changes. timer fires POSIX definition (not very helpful)

ASQF Fachgruppe Automation/ Automation Day 7 The POSIX Notification-API: Extensions(2) A device must be a possible source of a timer tick (clock) Example: A Profinet Realtime Ethernet Controller ERTEC provides for a 250 µsec tick, not necessarily synchronous with CLOCK_REALTIME  additional call register_clock() A firing timer is one special type of an event arbitrary asynchronous IO events should get signalled the same way  additional call event_create() Timer sigevent object SIGEV_THREAD (realtime capable implementation of the library module) CLOCK_REALTIME SIGEV_SIGNAL (inhibited) direct IO-Event create_event() Timer Device Driver clock register_clock() sigevent_set_notification() Signal to thread (optional with supervision) Extensions to the POSIX API

ASQF Fachgruppe Automation/ Automation Day 8 Realtime capable Linux: Base concept Linux kernel realtime kernel threads controlled by realtime scheduler threads controlled by Linux-Scheduler system call entry exactly the same for both kernels Ipipe (ADEOS) Common Library Linux Process POSIX API HW- Interrupts Soft- Interrupts static priorities (POSIX-counting) realtime kernel Linux Linux + Realtime boundary implementation defined Linux

ASQF Fachgruppe Automation/ Automation Day 9 Typical partitioning of a realtime thread setup phase time critical response path Much functionality needed but neither realtime requirements nor high performance requirements For all calls not implemented, the thread temporarily runs under the control of the Linux scheduler Wait for event event Realtime capable Linux: Functionality of the realtime kernel minimal functionality needed minimal realtime kernel -timer functions and its notification -communication and synchronization -scheduling

ASQF Fachgruppe Automation/ Automation Day 10 Realtime capable Linux: Limits of homogeneity Linux Kernel Realtime Kernel threads managed by the realtime scheduler threads managed by the Linux scheduler Ipipe Linux process HW- Interrupts Soft- Interrupts Signal source eg. timer Signal source eg. IO event A signal can only get sent to that domain which created the signal source This restriction is important for best possible performance (allows for separation of implementation) acceptable and manageable (violations are reported)

ASQF Fachgruppe Automation/ Automation Day 11 Realtime capable Linux: Implementation Kernel Two additional loadable modules: A device driver –functional extensions of the API (API-calls  ioctl() system calls, additional internal interfaces for realtime capable device drivers) –Interface for initialization/configuration of the realtime module eg. registration of a process as realtime process The realtime module (20K for x86) –Functionality of the realtime kernel –Communication between realtime and Linux kernel Three modified kernel files: –futex.c (hook), posix_timers.c (clock registration), mqueue.c Ipipe modifications: –Systemcall handling (additional hook at system call exit + optimization) –Interrupt handling (optimization, support for truly preemptive realtime kernel)

ASQF Fachgruppe Automation/ Automation Day 12 Realtime capable Linux: Implementation glibc Modified functions: Initialization –Registration of the realtime process Spinlock function also for static priorities Realtime capable implementation for SIGEV_THREAD Additional functions Device driver functions via ioctls –Registration of a timer clocks –Registration of an (IO-)event Thread specific sigevent notification (the kernel is able to do it) fast message queues

ASQF Fachgruppe Automation/ Automation Day 13 Testscenario: Measurement with getuid(), since getpid() is handled inside glibc Measurement with time stamp counter (94 clocks resp. 12/5 clocks) glibc generated with either int 80 or sysenter system entry (…/…) Cel. 2,8 GHz 1000 clocks = 357 ns Athlon 2 GHz 1000 clocks = 500 ns 343/147 Linux original ipipe original 1124/ /914 Linux Domain Realtime Domain Linux + Ipipe patch + AuD patch + AuD optimized + AuD patch + AuD optimized 1260/ / / /257 Realtime capable Linux: System call overhead in clocks 317/ / / /641 /185

ASQF Fachgruppe Automation/ Automation Day 14 high priority thread sem_post()/mq_send() sem_wait()/mq_receive() up helper thread of lowest priority down Low priority thread must have a chance to proceed to sem_wait() / mq_receive() sem_wait()/mq_receive() sem_post()/mq_send() low priority thread Realtime capable Linux: Performance inter-thread communication Testscenario: Two threads communicating either via semaphores or through POSIX message queues Note: Times for down are always longer than for up, since an additional sem_wait() / mq_receive()-call is included.

ASQF Fachgruppe Automation/ Automation Day 15 Realtime Domain Linux Domain up down up down up Realtime capable Linux: Interthread communication in clocks Celeron 2,8 GHz 1000 clocks = 357 ns Athlon 64 2,0 GHz 1000 clocks = 500 ns up down up down up down Semaphore Message Queue Semaphore Message Queue Times for Realtime  Linux first switch to interrupted Linux thread afterwards switch to woken up Linux thread (message queue) semaphores (futex) need an additional proxy thread for futex_wake optimized System call entry: int 80

ASQF Fachgruppe Automation/ Automation Day 16 Realtime Domain Linux Domain up down up down up Realtime capable Linux: Interthread communication in clocks Celeron 2,8 GHz 1000 clocks = 357 ns Athlon 64 2,0 GHz 1000 clocks = 500 ns up down up down up down Semaphore Message Queue Semaphore Message Queue optimized System call entry: sysenter Times for Realtime  Linux first switch to interrupted Linux thread afterwards switch to woken up Linux thread (message queue) semaphores (futex) need an additional proxy thread for futex_wake

ASQF Fachgruppe Automation/ Automation Day 17 ISR response thread response min max min max Athlon64 2,0 GHz 1000 clocks = 500 ns Celeron 2,8 GHz 1000 clocks = 357 ns Realtime capable Linux: Interrupt response time in clocks Test scenario: An application thread issues via a driver an ipipe soft interrupt The ISR resumes via send_event another application thread ( waiting with sigtimedwait()) ISR frequency varied between 100 µsec and 1 sec System load generated via GUI (Eclipse-Start, file transfer, etc.) The minimal figures are of interest in several respect: for high interrupt frequencies representative for the average and therefore the load typical for path length, and therefore useful for scalability projections What can be achieved with less powerful HW (e.g. SOC with mediocre memory interface )? for a dedicated processor of a multicore system (private TLB, L1-Cache, L2-Cache) the guaranteed worst case time comes closer to the minimal figure

ASQF Fachgruppe Automation/ Automation Day 18 Realtime capable Linux: Positioning to RT_PREEMPT The kernel implementation is transparent to application programs –An application binary for a dual domain system runs without any changes on a Linux only system and therefore also on a RT_PREEMPT system Possible coexistence scenarios with RT_PREEMPT –RT_PREEMPT as an alternative if no extremely strong realtime requirements –An additional realtime domain for extremely strong requirements for response time and thread communication, if demonstration is required (proof) tiny kernel, short paths  large complex kernel, lengthy paths, nested PI mutexes, RCU locks Commonalities with RT_PREEMPT – The same modifications of the glibc are needed. – The same kernel enhancements (registering a clock, realtime capable POSIX message queues) are needed

ASQF Fachgruppe Automation/ Automation Day 19 Realtime capable Linux: Conclusion The POSIX-Realtime-Extensions need some fine tuning –Minimal extensions to the API definition improve usability and allow for best possible performance Realtime under Linux can be provided transparently –The performance figures are comparable to specialized realtime kernels Ipipe is a sustainable base –Small optimizations improve system call handling and interrupt response