CSCI1600: Embedded and Real Time Software Lecture 27: Real Time Linux Steven Reiss, Fall 2015.

Slides:



Advertisements
Similar presentations
Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
Advertisements

Chapter 13 Embedded Systems
Chapter 13 Embedded Systems Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
CSE Fall Introduction - 1 What is an Embedded Systems  Its not a desktop system  Fixed or semi-fixed functionality (not user programmable)
Chapter 13 Embedded Systems
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
CprE 458/558: Real-Time Systems
The Design of Robust and Efficient Microkernel ManRiX, The Design of Robust and Efficient Microkernel Presented by: Manish Regmi
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Performance Evaluation of Real-Time Operating Systems
RTOS Design & Implementation Swetanka Kumar Mishra & Kirti Chawla.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Stack Management Each process/thread has two stacks  Kernel stack  User stack Stack pointer changes when exiting/entering the kernel Q: Why is this necessary?
Introduction to Embedded Systems
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating 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.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
Virtualization: Not Just For Servers Hollis Blanchard PowerPC kernel hacker.
Windows 2000 System Mechanisms Computing Department, Lancaster University, UK.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
The Performance of Micro-Kernel- Based Systems H. Haertig, M. Hohmuth, J. Liedtke, S. Schoenberg, J. Wolter Presentation by: Seungweon Park.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Fall 2013 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.
CSE 451: Operating Systems Section 5 Midterm review.
CS533 - Concepts of Operating Systems 1 The Mach System Presented by Catherine Vilhauer.
The Mach System Abraham Silberschatz, Peter Baer Galvin, and Greg Gagne Presented by: Jee Vang.
CSCI1600: Embedded and Real Time Software Lecture 18: Real Time Languages Steven Reiss, Fall 2015.
System Components ● There are three main protected modules of the System  The Hardware Abstraction Layer ● A virtual machine to configure all devices.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
CSCI1600: Embedded and Real Time Software Lecture 9: Input Output Concepts Steven Reiss, Fall 2015.
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
Real Time System with MVL. © 2007 MontaVista Confidential | Overview of MontaVista Agenda Why Linux Real Time? Linux Kernel Scheduler Linux RT technology.
CSCI1600: Embedded and Real Time Software Lecture 23: Real Time Scheduling I Steven Reiss, Fall 2015.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
Challenges in Porting & Abstraction. Getting Locked-In Applications are developed with a particular platform in mind The software is locked to the current.
CSCI1600: Embedded and Real Time Software Lecture 26: Real Time Operating Systems Steven Reiss, Fall 2015.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Operating Systems: Summary INF1060: Introduction to Operating Systems and Data Communication.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Low Overhead Real-Time Computing General Purpose OS’s can be highly unpredictable Linux response times seen in the 100’s of milliseconds Work around this.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Real-Time Operating Systems RTOS For Embedded systems.
Computer System Structures
Introduction to Real-Time Operating Systems
REAL-TIME OPERATING SYSTEMS
Chapter 19: Real-Time Systems
Memory Protection: Kernel and User Address Spaces
CS 6560: Operating Systems Design
Operating System Structure
Real-time Software Design
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
CSCI1600: Embedded and Real Time Software
Chapter 2: The Linux System Part 3
Operating Systems.
Operating Systems Lecture 1.
Chapter 19: Real-Time Systems
Chapter 2 Operating System Overview
Memory Protection: Kernel and User Address Spaces
Presentation transcript:

CSCI1600: Embedded and Real Time Software Lecture 27: Real Time Linux Steven Reiss, Fall 2015

Conventional Operating Systems  Memory model  Independent address spaces  Allocation and deallocation  Stack management  Device support  Abstraction based on descriptors  Clock and other basic devices built in  High-level I/O support (e.g. networking)  Thread / process model (with scheduling)  IPC support (pipes, sockets, shared memory)  Synchronization primitives

Conventional OS Problems  Size (for embedded)  Micro-kernel based architectures help here  Unpredictable (and poor) latency  Slow interrupt handlers  Unpreemptible kernel code  Latency might be built into hardware  System management interrupts on x86  DMA bus mastering; USB handling; VGA console; Page faults  Unpredictable Scheduling  Desktop/server heuristics  Scheduling overhead grows with workload  Poor support for precise timing  Timing accuracy related to tick overhead

Are the Problems Fixable?  Want to retain the bulk of prior work  Hundreds of device drivers  Many abstractions make programming easier  TCP/IP, File systems, IPC, Memory  How can we do this?  Two approaches to this are used  Fixing the problems  Sidestepping the problems

RT-Linux  Assume most of the program is non-real time  There is a small hard (soft) real-time component  Attempt to side step the problem  Run the OS as a real time task  Allow other RT tasks (outside the OS)  Provide the benefits of an OS and still have a real time environment  Except that Linux tasks are now sporadic

Linux on a RTOS  We’ve seen this before  Scheduling sporadic tasks  Bandwidth servers (Total and Constant)  Group all the sporadic tasks together  Provide a real-time task (with fixed bandwidth)  This executes the various sporadic tasks  Using their priorities  This is basically RT-Linux  Linux is “ported” to use RTOS primitives instead of hardware  Like running on a virtual machine

RT Linux

RT-Linux Details  RTLinux core  Non-preemptible  Hard real time scheduler  Basic OS functionality  Deterministic interrupt-latency ISRs run in core  Others are transferred to Linux via a FIFO  Primitive tasks  Only statically allocated memory, no virtual memory, fixed priority  Run as real time threads

RT-Linux Details  Real time tasks  No address space protection  Run with disabled interrupts  FIFO (message queue)  Connects real time tasks with LINUX  Shared memory synchronization  Non-real time tasks  Run as Linux processes

RT-Linux Pros and Cons  Pros  Hard real-time guarantees (low tens of microseconds)  OS code is virtually unchanged  Applies equally well to other OS’s  Supports BSD as well as Linux  Cons  Real time task lose the convenience of a mature well- understood API  Communication with Linux processes is ad-hoc  Message queues – but user needs to define the messages

Fixing the Problems  Problems to tackle  Scheduling, latency, timing  Techniques  Priority scheduling and priority inheritance  Limit un-preemptible code  Offer high-resolution timers

Scheduling  Real time schedulers are actually simpler  Support for fixed (absolute) priority  Ability to bind tasks to specific processors (cores)  Create new classes of processes (RR, FIFO)  Round robin runs for a fixed time slice  FIFO is never guaranteed  Enhance mutexes to support priority (PIP,PCP)  Problem: scheduling latency  Support fixed priorities  But scheduling decisions might be deferred  Interrupt handlers cannot be preempted  Spin-locked code can not be preempted

Minimizing Latency  Simple Solution:  Threaded interrupt handling  Move interrupt handlers into kernel threads; true ISR is now very short  Handling can be preempted  Preemptible spin locks  Turn spin locks into mutexes  This almost works  Timer interrupts need to be handled directly  Individual handlers are still atomic  Spinlocks not always equivalent to mutexes  Programming devices, modifying page tables, in the scheduler  Read-copy-update synchronization in Linux make non-preemption assumptions  New type: raw_spinlock_t

Other Improvements  Dynamic tick  Ask for timer IRQ as needed, not periodically  High resolution timers  O(1) scheduler  Robust mutexes  O(1) kernel memory allocation  Ability to lock pages into memory (avoid page faults)  Most problems can be minimized  But retrofitting them to an OS make hard real time unlikely

Solaris  Attempt to fix the problems  Starting with the initial OS design  Not retrofitted  Features of Solaris for real time  Interrupts are handled by threads  Kernel is fully preemptible and multithreaded  Real time scheduling is supported  Deterministic with real time priorities  Fixed priority scheduling supported

Solaris Real Time Threads  Separate classes of threads  Fixed-priority (non-varying)  But lower priority than Operating System  Real-Time (fixed priority with fixed quantum)  Higher priority than operating system  Real time threadss  Lock their pages in memory  Can call OS (but then run at lower priority)

Solaris Features  Priority inheriting synchronization primitives  Processor sets  The ability to isolate one or more CPUs for scheduling  Ability to lock tasks to a particular core  Full support for the Posix real time standard  Real time threads  High-precision timers and clocks  Fast TCP/IP (zero copy)  Memory locking  Early binding of shared libraries

Solaris  Has been used as a hard real time environment  But not as an embedded environment  Too large

Embedded Linux  Linux is a common tool for embedded systems  Linux itself is relatively small  Linux is fairly modular  It can run in 1M (or less) of memory

Requirements on RT/Embedded  Safety Requirements  The car won’t crash  Trains won’t crash  Both traffic lights won’t be green at the same time  You won’t blow a fuse  The system won’t deadlock  The heat and air conditioning won’t be on at the same time

More Requirements: Timing  Forms  X will occur within k ms of event Y  X will occur every 10 +/- 1 ms  Examples  The solenoid will trigger within 10 ms of the bumper being hit  The switches will be sensed every 20 ms  The heat will come on within 5 minutes of detecting the room is too cool

More Requirements: Fairness  Forms  Eventually X will occur  If X occurs, then eventually Y will occur  X will occur infinitely often  As long as Y is true, X will occur infinitely often  Examples  Eventually you will add K to the score when you hit Y  As long as the heating system is on, the room will eventually be comfortable

Requirements  Are often mandatory (hard)  Failure is not a viable option  Car or plan crashes  Broken devices  Heart stops pumping  Water is supplied unfiltered  The nuclear plant does not shut down  This is what hard real time means

What Are Your Requirements?

Problems  How do you show the system is safe  How do you get confidence in the system’s safety  When can you reasonably deploy the system  Can the system be used in a medical device  Can peoples lives depend on the system

Exercise  Suppose you wanted to sell your tic-tac-toe box  What would you want as requirements  How would you check these?  Take the ankle-mounted obstacle finder example  What would be the requirements  How would you check these?

Helpful Techniques: SE  Good requirements analysis  Understanding all the possible problems and solutions  Good specifications  Accurate modeling  Showing the models are correct  Petri net and FSA validation  Design for security  Defensive coding  Building monitors as part of the code  Enter a safe state if the monitor detects anything wrong  Enter a safe state if the monitor detects anything unusual  Checking tools: lint, compiler, modeling analysis

Homework  Read chapter 13