EMERALDS: a small-memory real-time microkernel

Similar documents
ACM SOSP 99 paper by Zuberi et al.

EMERALDS: a small-memory real-time microkernel

EMERALDS: A Small-Memory Real-Time Microkernel

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

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

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

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

Introduction to Embedded Systems

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University


OPERATING SYSTEM CONCEPTS UNDERSTAND!!! IMPLEMENT!!! ANALYZE!!!

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

Systemy RT i embedded Wykład 11 Systemy RTOS

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

NuttX Realtime Programming

Multiprocessor Systems. COMP s1

Operating System Design Issues. I/O Management

Real-Time Programming

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

Multiprocessor System. Multiprocessor Systems. Bus Based UMA. Types of Multiprocessors (MPs) Cache Consistency. Bus Based UMA. Chapter 8, 8.

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

Exam Review TexPoint fonts used in EMF.

8: Scheduling. Scheduling. Mark Handley

Chapter 13: I/O Systems

Main Points of the Computer Organization and System Software Module

Multiprocessor and Real-Time Scheduling. Chapter 10

Reference Model and Scheduling Policies for Real-Time Systems

CS4514 Real Time Scheduling

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

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Scheduling Algorithm and Analysis

MARUTHI SCHOOL OF BANKING (MSB)

Operating Systems, Fall

(b) External fragmentation can happen in a virtual memory paging system.

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

Chapter 13: I/O Systems

Embedded Systems: OS

* There are more than 100 hundred commercial RTOS with memory footprints from few hundred kilobytes to large multiprocessor systems

Multiprocessor Systems. Chapter 8, 8.1

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

Multiprocessor Support

Lightweight Remote Procedure Call. Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented by Alana Sweat

Computer Systems Assignment 4: Scheduling and I/O

Microkernel/OS and Real-Time Scheduling

Introduction. Real Time Systems. Flies in a bottle. Real-time kernel

JOURNAL OF CIRCUITS AND SYSTEMS September, (2002) HDTV RTOS [1] [2] [3] [4]

Process Scheduling Part 2

2 nd Half. Memory management Disk management Network and Security Virtual machine

The control of I/O devices is a major concern for OS designers

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

Operating Systems: Quiz2 December 15, Class: No. Name:

ECE519 Advanced Operating Systems

Process- Concept &Process Scheduling OPERATING SYSTEMS

RTOS Real T i Time me Operating System System Concepts Part 2

Chapter 13: I/O Systems

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

Chapter-6. SUBJECT:- Operating System TOPICS:- I/O Management. Created by : - Sanjay Patel

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

Overview. Sporadic tasks. Recall. Aperiodic tasks. Real-time Systems D0003E 2/26/2009. Loosening D = T. Aperiodic tasks. Response-time analysis

Microkernel Construction

VALLIAMMAI ENGINEERING COLLEGE

Performance and Optimization Issues in Multicore Computing

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

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

Multimedia Systems 2011/2012

Linux (Fedora or Slackware) CPU Scheduling

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Real-Time Systems. Real-Time Operating Systems

REAL-TIME OVERVIEW SO FAR MICHAEL ROITZSCH. talked about in-kernel building blocks:

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Operating System Architecture. CS3026 Operating Systems Lecture 03

Concept of a process

Threads, SMP, and Microkernels

CEC 450 Real-Time Systems

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

1995 Paper 10 Question 7

Introduction to Real-Time Systems and Multitasking. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Tasks. Task Implementation and management

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Chapter 13: I/O Systems. Objectives. I/O Hardware. A Typical PC Bus Structure. Device I/O Port Locations on PCs (partial)

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

Processes and Non-Preemptive Scheduling. Otto J. Anshus

CS A320 Operating Systems for Engineers

Embedded Systems. 6. Real-Time Operating Systems

Learning Outcomes. Scheduling. Is scheduling important? What is Scheduling? Application Behaviour. Is scheduling important?

Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies

Device-Functionality Progression

Chapter 12: I/O Systems. I/O Hardware

Chapter 3: Processes. Operating System Concepts 8 th Edition,

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

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

Timers 1 / 46. Jiffies. Potent and Evil Magic

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

Chapter 3: Process Concept

Chapter 3: Process Concept

Inter-Process Communication and Synchronization of Processes, Threads and Tasks: Lesson-1: PROCESS

Transcription:

EMERALDS: a small-memory real-time microkernel By Khawar M. Zuberi, Padmanabhan Pillai, and Kang G. Shin 4/28/2005 CMSC 691S Real-Time Systems 1

Outline Introduction Requirements EMERALDS Overview CSD Scheduler Semaphore implementation Inter-task communication Conclusion 4/28/2005 CMSC 691S Real-Time Systems 2

Introduction EMERALDS = Extensible Microkernel for Embedded, ReAL-time Distributed Systems Most RTOS were designed for powerful systems Real-time embedded controllers are getting popular, running on top of minimal hardware Implement core OS services using optimized, carefully crafted code EMERALDS s approach: new OS schemes and algorithms Small kernel and application code size Priori knowledge of task communication and execution pattern to reduce overhead 4/28/2005 CMSC 691S Real-Time Systems 3

Requirements Slow processing speed (15-25 MHz) for single chip micro-controllers Limited ROM/RAM size (32-128 kbyte) 20 kbytes RTOS kernel code size Uniprocessor or distributed nodes Low speed field bus network (1-2 Mbps) Design goal 10-20 concurrent, periodic real-time tasks Interrupt and I/O services No disk or file system support Task synchronization, communication and clock service 4/28/2005 CMSC 691S Real-Time Systems 4

EMERALDS Overview A micro-kernel RTOS written in C++ Features supported Multi-threaded processes IPC (message passing, mailboxes and shared memory) Semaphores and condition variables Communication protocol stacks Optimized context switching and interrupt handling User level device drivers 4/28/2005 CMSC 691S Real-Time Systems 5

Scheduling in embedded applications 1 st try: cyclic time-slice scheduling Calculate entire schedule offline Modification of schedule due to task characteristic change is difficult and costly High-priority aperiodic task has poor response time Result in large time-slice schedules if work load contains short and long period tasks 4/28/2005 CMSC 691S Real-Time Systems 6

CSD Scheduler Priority driven scheduler: a combination of EDF and RM 2 components of task scheduler overhead Run-time overhead Schedulability overhead 4/28/2005 CMSC 691S Real-Time Systems 7

Run-time overhead Time consumed by executing scheduler code Parsing queue tasks, add/delete tasks from queue Blocking overhead ( tb) Unblocking overhead ( tu) Selection overhead ( ts) Total overhead in each period when blocking system calls are used t = 1.5( tb + tu + 2 ts) Total workload utilization U = (Ci + t)/pi, i = 1 ~ n 4/28/2005 CMSC 691S Real-Time Systems 8

Overhead comparison between EDF and RM EDF overhead (single, unsorted queue) tb, tu: O(1) ts: O(n) RM overhead (single, sorted queue) tb: O(n) (set pointer point to next ready task) tu: O(1) ts: O(1) RM has significant less run-time overhead than EDF since t = 1.5( tb + tu + 2 ts) 4/28/2005 CMSC 691S Real-Time Systems 9

Schedulability overhead Defined as 1 U*, where U* is the idea schedulable utilization Utilization U = ci/pi, i = 1 ~ n U* = 1 for EDF no schdulability overhead U* = 0.88 (0.69!?) for RM 4/28/2005 CMSC 691S Real-Time Systems 10

CSD: a mixed approach CSD = Combined Static/Dynamic Given a workload, it may be feasible under EDF but not RM Identify the trouble maker : the task that is schedulable in EDF but infeasible in RM Use EDF for tasks that has higher rate up to the troublesome task Use RM for the remaining tasks 4/28/2005 CMSC 691S Real-Time Systems 11

Example workload i 1 2 3 4 5 6 7 8 9 10 Pi (ms) ci (ms) 4 5 6 7 8 20 30 50 100 130 1.0 1.0 1.0 1.0 0.5 0.5 0.5 0.5 0.5 0.5 4/28/2005 CMSC 691S Real-Time Systems 12

CSD (con t) Maintain 2 queues of tasks Dynamic priority (DP) queue for EDF Fixed priority (FP) queue for RM DP queue is given higher priority Execute tasks in DP queue if at least one task is ready Otherwise pick one from FP queue with highest priority ready task 4/28/2005 CMSC 691S Real-Time Systems 13

Run-time overhead of CSD 4 possible cases DP task blocks: tb = O(1), ts = O(r) DP task unblocks: tu = O(1), ts = O(r) FP task blocks: tb = O(n-r), ts = O(1) FP task unblocks: tu = O(1), ts = O(r) Total CSD overhead tb + ts_block + tu + ts_unblock DP: O(1) + O(r) + O(1) + O(r) = 2O(r) FP: O(n-r) + O(1) + O(1) + O(r) = O(n) 4/28/2005 CMSC 691S Real-Time Systems 14

Reducing CSD run-time overhead CSD reduces runtime overhead by keeping DP queue length short As number of tasks increases, performance degrades rapidly Solution: split DP queue into sub-queues CSD-3: 2 DP queues (DP1 & DP2) + 1 FP queue DP1 contains tasks having the shortest periods, reduction in overhead greatly improves performance 4/28/2005 CMSC 691S Real-Time Systems 15

Task allocating into sub queues When tasks have different periods Keep only few tasks in DP1 to keep t(dp1) small Multiple DP queues will result in non-zero schedulability overhead Beyond CSD-3 Increase in schedulability overhead will exceed reduction in runtime overhead as number of queues gets larger 2 extreme cases: 1 queue and n queues are equivalent to RM 4/28/2005 CMSC 691S Real-Time Systems 16

CSD Performance 4/28/2005 CMSC 691S Real-Time Systems 17

CSD Performance (period scale down by 2) 4/28/2005 CMSC 691S Real-Time Systems 18

CSD Performance (period scale down by 3) 4/28/2005 CMSC 691S Real-Time Systems 19

Semaphore Implementation Standard semaphore implementation If (sem locked) { do priority inheritance; add caller thread to wait queue; block; //and wait for sem to be released } Lock sem 4/28/2005 CMSC 691S Real-Time Systems 20

Semaphore Implementation (Con t) Need Priority inheritance to avoid unbounded priority inversion 4/28/2005 CMSC 691S Real-Time Systems 21

Reduce context switches 4/28/2005 CMSC 691S Real-Time Systems 22

Reduce context switches (Con t) Rethink priority inheritance for both DP and FP tasks Letting lower priority task who holds semaphore continue to execute Passing extra parameter to indicate which semaphore to lock when calling acquire_sem() 4/28/2005 CMSC 691S Real-Time Systems 23

Reducing Context switches for FP tasks O(n-r) complexity for normal queue operation Optimizing priority inheritance to O(1) Insert T1 directly ahead of T2 (T1 inherits T2 s priority) Swap position in queue between T1 and T2 (return T1 to its original priority) If thread T3 came in while T1 inherits T2 s priority Swap between T1 and T3, and put T2 back Require FP to keep ready and blocked tasks in the same queue 4/28/2005 CMSC 691S Real-Time Systems 24

Analysis of new scheme What if thread T2 does not block on acquire_sem? Is it save to delay T2? 4/28/2005 CMSC 691S Real-Time Systems 25

What if T1 has higher priority? T2 incurs full overhead of acquire_sem() Sol: block T2 when higher priority thread locks S, and unblock T2 when S is released 4/28/2005 CMSC 691S Real-Time Systems 26

Semaphore scheme performance (DP) 4/28/2005 CMSC 691S Real-Time Systems 27

Semaphore scheme performance (FP) 4/28/2005 CMSC 691S Real-Time Systems 28

Inter-task communication Traditional Mechanism: mailbox Invoke system call to send message High overhead Need to send same message multiple times to multiple tasks Solutions Global variables State message passing 4/28/2005 CMSC 691S Real-Time Systems 29

State message semantics Solve single writer, multiple reader problem A mailbox is associated with a writer One writer sends message to SMmailbox Multiple readers can receive message New message overwrites old one Reads do not consume message Both reads and writes are non-blocking 4/28/2005 CMSC 691S Real-Time Systems 30

State message implementation B: max number of bytes CPU can read/write L: message length Simple case: L B If L > B assign N-deep circular buffer to each state message Each message has a 1-byte index 4/28/2005 CMSC 691S Real-Time Systems 31

Calculate buffer depth N x: number of write operations can occur while reader is blocked N = max(2, xmax + 1) maxreadtime = d (c - cr) = (d c) + cr d: deadline c: execution time cr: read execution time 4/28/2005 CMSC 691S Real-Time Systems 32

Calculate max write times xmax -1 = floor[(maxreadtime (Pw - dw))/pw] pw: writer s period dw: writer s deadline 4/28/2005 CMSC 691S Real-Time Systems 33

Conclusions EMERALDS provides key OS services with significantly lower overhead CSD scheduler creates balance between static and dynamic scheduling New semaphore reduces context switch and priority inheritance overhead by 20~30% State-message paradigm incurs ¼~1/5 overhead Future work Networking issues 4/28/2005 CMSC 691S Real-Time Systems 34