Real-Time Operating Systems (Working Draft) What is an Operating System (OS)?

Similar documents
Real-Time Operating Systems Design and Implementation. LS 12, TU Dortmund

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

Embedded Systems. 6. Real-Time Operating Systems

Real-Time & Embedded Operating Systems

EECS 571 Principles of Real-Time Embedded Systems. Lecture Note #10: More on Scheduling and Introduction of Real-Time OS

Commercial Real-time Operating Systems An Introduction. Swaminathan Sivasubramanian Dependable Computing & Networking Laboratory

EMBEDDED OPERATING SYSTEMS

Real-Time Systems. Real-Time Operating Systems

Real-Time Systems Hermann Härtig Real-Time Operating Systems Brief Overview

RT extensions/applications of general-purpose OSs

ERIKA Enterprise Minimal API Manual....multithreading on a thumb!

Outline Background Jaluna-1 Presentation Jaluna-2 Presentation Overview Use Cases Architecture Features Copyright Jaluna SA. All rights reserved

REAL TIME OPERATING SYSTEM PROGRAMMING-I: VxWorks

Module 1. Introduction:

Chapter 3 Process Description and Control

A Predictable RTOS. Mantis Cheng Department of Computer Science University of Victoria

Operating Systems Overview. Chapter 2

Reference Model and Scheduling Policies for Real-Time Systems

REAL-TIME OPERATING SYSTEMS SHORT OVERVIEW

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Real-Time Programming

Timers 1 / 46. Jiffies. Potent and Evil Magic

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Department of Computer Science Institute for System Architecture, Operating Systems Group REAL-TIME MICHAEL ROITZSCH OVERVIEW

Concurrent Programming

Zilog Real-Time Kernel

Embedded Systems: OS

The Real Time Thing. What the hack is real time and what to do with it. 22C3 30. December Erwin Erkinger e.at

6/20/2018. Lecture 2: Platforms & RTOS. Outline. Lab Setup (20 min) Labs work. Lecture: Platform + RTOS

CSE 237A Middleware and Operating Systems. Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.

Concurrent Programming. Implementation Alternatives. Content. Real-Time Systems, Lecture 2. Historical Implementation Alternatives.

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

ZiLOG Real-Time Kernel Version 1.2.0

AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel. Alexander Züpke, Marc Bommert, Daniel Lohmann

Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

Process Description and Control

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

TDDD07 Real-time Systems Lecture 10: Wrapping up & Real-time operating systems

AMSC/CMSC 662 Computer Organization and Programming for Scientific Computing Fall 2011 Operating Systems Dianne P. O Leary c 2011

Outline. Introduction. Survey of Device Driver Management in Real-Time Operating Systems

DSP/BIOS Kernel Scalable, Real-Time Kernel TM. for TMS320 DSPs. Product Bulletin

CS370 Operating Systems

Operating Systems. Lecture Course in Autumn Term 2015 University of Birmingham. Eike Ritter. September 22, 2015

Operating Systems Fundamentals. What is an Operating System? Focus. Computer System Components. Chapter 1: Introduction

Lesson 5: Software for embedding in System- Part 2

OPERATING SYSTEMS UNIT - 1

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Real-time for Windows NT

Micrium µc/os II RTOS Introduction EE J. E. Lumpp

Four Components of a Computer System

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

Following are a few basic questions that cover the essentials of OS:

Real-time Support in Operating Systems

I/O Systems (3): Clocks and Timers. CSE 2431: Introduction to Operating Systems

SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road QUESTION BANK (DESCRIPTIVE) UNIT I OPERATING SYSTEMS

Operating System Review

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)

Lecture notes Lectures 1 through 5 (up through lecture 5 slide 63) Book Chapters 1-4

Introduction. TDDI04, K. Arvidsson, IDA, Linköpings universitet Contents. What is an Operating System (OS)?

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

A New Real-time Kernel development on an embedded platform

Course Details. Operating Systems with C/C++ Course Details. What is an Operating System?

LINUX OPERATING SYSTEM Submitted in partial fulfillment of the requirement for the award of degree of Bachelor of Technology in Computer Science

Module 20: Multi-core Computing Multi-processor Scheduling Lecture 39: Multi-processor Scheduling. The Lecture Contains: User Control.

OVERVIEW. Last Week: But if frequency of high priority task increases temporarily, system may encounter overload: Today: Slide 1. Slide 3.

Systemy RT i embedded Wykład 11 Systemy RTOS

Chapter 1: Introduction

UNIT I OPERATING SYSTEMS OVERVIEW

7/20/2008. What Operating Systems Do Computer-System Organization

CSC Operating Systems Fall Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. August 27 th, 2009.

Announcements. Computer System Organization. Roadmap. Major OS Components. Processes. Tevfik Ko!ar. CSC Operating Systems Fall 2009

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

1. Draw and explain program flow of control without and with interrupts. [16]

Chapter 1: Introduction


Module 1: Introduction

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

The Xenomai Project. The Open Group Conference Paris, April Open Source Engineering

Software Development & Education Center

Process Description and Control. Chapter 3

6/17/2011. Real-time Operating Systems

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

Chapter 1: Introduction

Operating Systemss and Multicore Programming (1DT089)

Chapter 1: Introduction

CS370 Operating Systems

Implementation Alternatives. Lecture 2: Implementation Alternatives & Concurrent Programming. Current Implementation Alternatives

CS533 Concepts of Operating Systems. Jonathan Walpole

operating system Spring 2017 Prof.Dr. Hasan Balik Student Name : Walid.W. Ramadan mansour Student ID :

Handout. The ARM Instruction Set. Real Time Systems. Real Time Operating Systems. Real Time System Organization. Classification of Real Time Systems

SMD149 - Operating Systems

Micrium OS Kernel Labs

e-ale-rt-apps Building Real-Time Applications for Linux Version c CC-BY SA4

Abstract. Testing Parameters. Introduction. Hardware Platform. Native System

Overview. Thread Packages. Threads The Thread Model (1) The Thread Model (2) The Thread Model (3) Thread Usage (1)

CSE 4/521 Introduction to Operating Systems. Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018

Operating System Design Issues. I/O Management

Transcription:

Real-Time Operating Systems (Working Draft) Originally Prepared by Sebastian Fischemeister Modified by Insup Lee CIS 541, Spring 2010 What is an Operating System (OS)? A program that acts as an intermediary between a user of a computer and the computer hardware Operating system goals: o Execute user programs and make solving user problems easier. o Make the computer system convenient to use Use the computer hardware in an efficient manner Spring 10 CIS 541 2

Computer System Components 1. Hardware provides basic computing resources (CPU, memory, I/O devices) 2. Operating system controls and coordinates the use of the hardware among the various application programs for the various users 3. Applications programs define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs) 4. Users (people, machines, other computers) Spring 10 CIS 541 3 Abstract View of System Components Spring 10 CIS 541 4

What is an RTOS (Real-Time OS)? Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems Well-defined fixed-time constraints Spring 10 CIS 541 5 More Precisely? The system allows access to sensitive resources with defined response times. o Maximum response times are good for hard real-time o Average response times are ok for soft real-time Any system that provides the above can be classified as a real-time system o 10us for a context switch, ok? o 10s for a context switch, ok? Spring 10 CIS 541 6

Taxonomy of RTOSs Small, fast, proprietary kernels RT extensions to commercial timesharing systems Component-based kernels Monolithic kernels Spring 10 CIS 541 7 Small, Fast, Proprietary Kernels They come in two varieties: o Homegrown o Commercial offerings Usually used for small embedded systems Typically specialized for one particular application Typically stripped down and optimized versions: o Fast context switch o Small size, limited functionality o Low interrupt latency o Fixed or variable sized partitions for memory management PICOS18, psos, MicroC, Spring 10 CIS 541 8

RT Extensions A common approach is to extend Unix o Linux: RT-Linux, RTLinuxPro, RTAI, o Posix: RT-Posix o MACH: RT-MACH Also done for Windows based on virtualization. Generally slower and less predictable. Richer environment, more functionality. These systems use familiar interfaces, even standards. Problems when converting an OS to an RTOS: o Interface problems (nice and setpriority in Linux) o Timers too coarse o Memory management has no bounded execution time o Intolerable overhead, excessive latency Spring 10 CIS 541 9 How to do an RT Extension? Compliant kernels o Takes an existing RTOS and make it execute other UNIX binaries (see LynxOS). o Interfaces need to be reprogrammed. o Behavior needs to be correctly reimplemented. Spring 10 CIS 541 10

How to do an RT Extension? Dual kernels o Puts an RTOS kernel between the hardware and the OS. o Hard tasks run in the RTOS kernel, the OS runs when CPU is available. o Native applications can run without any changes. o Hard tasks get real-time properties. o See RTLinuxPro Problems: A single failing hard task can kill the whole system. The RTOS kernel requires its own IO drivers. Spring 10 CIS 541 11 How to do an RT Extension? Core kernel modifications o Takes the non-rt operating systems and modifies it to become an RTOS. Problem: (need to do all this) o Implement high-resolution timers o Make the kernel preemptive o Implement priority inheritance o Replace FIFOs with priority queues o Find and change long kernel execution paths Spring 10 CIS 541 12

Component-based Kernels The source consists of a number of components that can be selectively included to compose the RTOS. See OS-Kit, Coyote, PURE, 2k, MMLite, Pebble, Chaos, ecos. ecos o Hardware Abstraction Layer (HAL) o Real-time kernel Interrupt handling Exception handling Choice of schedulers Thread support Rich set of synchronization primitives Timers, counters and alarms Choice of memory allocators Debug and instrumentation support Counters -- Count event occurrences Clocks -- Provide system clocks Alarms -- Run an alarm function Mutexes -- Synchronization primitive Condition Variables -- Synchronization primitive Semaphores -- Synchronization primitive Mail boxes -- Synchronization primitive Event Flags -- Synchronization primitive Spinlocks -- Low-level Synchronization Primitive Scheduler Control -- Control the state of the scheduler Interrupt Handling -- Manage interrupt handlers Spring 10 CIS 541 13 Component-based Kernels ecos o µitron 3.0 compatible API o POSIX compatible API o ISO C and math libraries o Serial, ethernet, wallclock and watchdog device drivers o USB slave support o TCP/IP networking stacks o GDB debug support All components can be added through a configuration file that includes and excludes parts of the source code. Spring 10 CIS 541 14

Research Kernels Many researchers built a new kernel for one of these reasons: o Challenge basic assumptions made in timesharing OS o Developing real-time process models o Developing real-time synchronization primitives o Developing solutions facilitating timing analysis o Strong emphasis on predictability o Strong emphasis on fault tolerance o Investigate the object-oriented approach o Real-time multiprocessor support o Investigating QoS Spring 10 CIS 541 15 What Typically Differs

Requirements RTOS must be predictable o We have to validate the system o We have to validate the OS calls/services We must know upper bounds to o Execution time of system calls o Memory usage We must have static bounds on o Memory layout o Size of data structures (e.g. queues) Fine grain interrupt control Spring 10 CIS 541 17 RTOS Predictability All components of the RTOS must be predictable o System calls, device drivers, kernel internal management Memory access o Page faults, lookup time, caches Disk access o Bound for head movement while reading/writing data Net access o Bound for time for transmission, switching o Dropped packets?? Scheduling must be deterministic Spring 10 CIS 541 18

Admission Control Admission control is a function that decides if new work entering the system should be admitted or not. To perform this it requires: o A model of the state of system resources o Knowledge about incoming requests o An algorithm to make the admission decision o Policies for actions to take upon admission and rejection Statically scheduled systems require no admission control. Spring 10 CIS 541 19 Admission Control The admission algorithm requires preanalyzed tasks Shared data Execution time Precedence information Importance level Deadlines Positive decision assigns time slices to the task Negative decision has options: o Run a simpler version of the task o Run on a different machine o Reject the task Admission algorithms can be complex as they have to consider multiple resources (e.g., networked video streaming). Spring 10 CIS 541 20

Resource Reservation Resource reservation is the act of actually assigning resources to a task. o Initially no resource reservation, only allocation as the task runs. o Valuable for hard real-time systems. o Introduces an overhead as resources might be unused => introduction of resource reclaiming strategies Closely linked to resource kernels that offer interfaces for resource reservation, donation, and reflection. Spring 10 CIS 541 21 Task Declaration RTOSs tailored to microprocessors often require a static declaration of tasks. Advantages are: o Simple check that the system has sufficient resources. o No admission control necessary. o No overhead introduced by the admission test. o No thread spawning problems => but quite static Spring 10 CIS 541 22

Boot from ROM The RTOS typically boots from the ROM when used on microprocessors. Requires the application program to actually start up the RTOS: void main (void) { /* Perform Initializations */... OSInit();... /* Create at least one task by calling OSTaskCreate() */ OSStart(); } Spring 10 CIS 541 23 Configurability As mentioned with component-based RTOS, the system must be configurable. Include only components needed for the present system Components must be removable o Inter-module dependencies limit configurability Configuration tailors OS to system o Different configuration possibilities Example RoboVM (PICDEM and modular robot). Spring 10 CIS 541 24

Configurability Remove unused functions o May be done via linker automatically Replace functionality o Motor placement comes in three functions: Calculated Lookup table (program memory) Lookup table (EEPROM) Conditional compilation o Use #if, #ifdef constructs o Needs configuration editor o Example: Linux make config. Spring 10 CIS 541 25 Problem with Configurability Per (boolean) configuration option, we obtain two new OS versions. Embedded systems require extensive testing. The application must be tested with each configuration separately: o 100 configuration options we get around 2^100 o Require hardware setup o Require software setup o Require reporting for automated testing Spring 10 CIS 541 26

Embedded RTOS I/O I/O normally only through kernel via a system call. o Expensive but provides control In an RTOS for embedded systems, tasks are allowed to do I/O operations directly o Direct fast access o Direct task to task communication between chips Problem: Can cause troubles if tasks interfere Solution: Programmer must do synchronization too Spring 10 CIS 541 27 Embedded RTOS: Interrupts Normal OS: Interrupts are kernel only o Must be reliable (dropped disk interrupts ) o Costly: Notification via context switch/syscalls Embedded OS: tasks can use interrupts o Again: only trusted/tested programs o Speed important o Fast task control possible o But: modularity decreases, as tasks may have to share interrupts correctly Spring 10 CIS 541 28

PICOS18 Interrupt Routine Part of the user application. One for the high priority interrupts and one for low priority interrupts. Most important part: AddOneTick() Let s have a look. Spring 10 CIS 541 37 PICOS18 Context Switch The active task gets suspended and its context gets pushed onto its stack. The preempted task gets resumed and its context gets restored. Let s have look at the save_task_ctx routine. Spring 10 CIS 541 38

Static Declarations PICOS18 requires you to statically declare o Alarms o Resources o Tasks Let s have a look. Spring 10 CIS 541 39 Tasks Implementation At most 16 events. The task state is encoded in the following variables: o tsk_x_state_id Bits 0-3: task identifier Bit 4: unused Bit 5-7: task state o tsk_x_active_prio Bits 0-3: task priority Bit 5-7: activation counter o Let s look at some of the functions in pro_man.c Spring 10 CIS 541 41

Event Management StatusType SetEvent (TaskType TaskID, EventMaskType Mask) o Posts an event to another task. Causes a scheduling operation. StatusType ClearEvent (EventMaskType Mask) o Clears the event, otherwise an infinite loop. StatusType GetEvent (TaskType TaskID, EventMaskRefType Event) o Receives the event value for a specific task. StatusType WaitEvent (EventMaskType Mask) o Blocks the current task until the event occurs. Spring 10 CIS 541 42 Event Implementation At most 16 events. The event status is encoded in these two variables: o EventMaskType event_x For each task 16 possible events. o EventMaskType wait_x Each task can listen for 16 possible events. Let s have a look at the code. Spring 10 CIS 541 43

Alarm Management StatusType GetAlarm (AlarmType AlarmID, TickRefType Tick) o Returns the number of ticks until the alarm goes off. StatusType SetRelAlarm (AlarmType AlarmID, TickType increment, TickType cycle) o Registers an alarm relative to the current kernel counter. StatusType SetAbsAlarm (AlarmType AlarmID, TickType start, TickType cycle) o Registers an alarm as absolute kernel counter tick value. StatusType CancelAlarm (AlarmType AlarmID) o Deactivate an alarm. Spring 10 CIS 541 44 Alarm Implementation Each tick the alarm counters get incremented by one. If the alarm value equals the counter value, then the alarm will cause an event. Let s look at the code. Spring 10 CIS 541 45

Sample Application Let s look at the sample application that comes with PICOS18. Spring 10 CIS 541 46