Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

Similar documents
3. Scheduling issues. Common approaches /1. Common approaches /2. Common approaches / /13 UniPD / T. Vardanega 23/01/2013. Real-Time Systems 1

Lecture 3 Theoretical Foundations of RTOS

Real-Time Software. Basic Scheduling and Response-Time Analysis. René Rydhof Hansen. 21. september 2010

Common Approaches to Real-Time Scheduling

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Module 6. Embedded System Software. Version 2 EE IIT, Kharagpur 1

Periodic Task Scheduling

Real Time Scheduling Basic Concepts. Radek Pelánek

4. Fixed-Priority Scheduling

174: Scheduling Systems. Emil Michta University of Zielona Gora, Zielona Gora, Poland 1 TIMING ANALYSIS IN NETWORKED MEASUREMENT CONTROL SYSTEMS

Aperiodic Task Scheduling

Priority-Driven Scheduling

Today. Intro to real-time scheduling Cyclic executives. Scheduling tables Frames Frame size constraints. Non-independent tasks Pros and cons

The simple case: Cyclic execution

Real-time Scheduling of Periodic Tasks (1) Advanced Operating Systems Lecture 2

Aperiodic Task Scheduling

Operating System Aspects. Real-Time Systems. Resource Management Tasks

Predictable response times in event-driven real-time systems

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Effective Scheduling Algorithm and Scheduler Implementation for use with Time-Triggered Co-operative Architecture

Commonly Used Approaches to Real-Time Scheduling

Advanced Operating Systems (M) Dr Colin Perkins School of Computing Science University of Glasgow

Multi-core real-time scheduling

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Real- Time Scheduling

Partition Scheduling in APEX Runtime Environment for Embedded Avionics Software

Real-time scheduling algorithms, task visualization

SOFTWARE VERIFICATION RESEARCH CENTRE THE UNIVERSITY OF QUEENSLAND. Queensland 4072 Australia TECHNICAL REPORT. No Real-Time Scheduling Theory

ICS Principles of Operating Systems

CPU Scheduling. CPU Scheduling

Scheduling Aperiodic and Sporadic Jobs in Priority- Driven Systems

Scheduling Real-time Tasks: Algorithms and Complexity

Resource Reservation & Resource Servers. Problems to solve

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Classification - Examples

Improved Handling of Soft Aperiodic Tasks in Offline Scheduled Real-Time Systems using Total Bandwidth Server

Performance of Algorithms for Scheduling Real-Time Systems with Overrun and Overload

On-line scheduling algorithm for real-time multiprocessor systems with ACO

HARD REAL-TIME SCHEDULING: THE DEADLINE-MONOTONIC APPROACH 1. Department of Computer Science, University of York, York, YO1 5DD, England.

Modular Real-Time Linux

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

W4118 Operating Systems. Instructor: Junfeng Yang

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Efficient Scheduling Of On-line Services in Cloud Computing Based on Task Migration

Workload Models for System-Level Timing Analysis: Expressiveness vs. Analysis Efficiency

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

OPERATING SYSTEMS SCHEDULING

Scheduling Algorithms for Real-Time Systems

Operating Systems. III. Scheduling.

LAB 5: Scheduling Algorithms for Embedded Systems

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

Aperiodic Task Scheduling for Real-Time Systems. Brinkley Sprunt

CPU Scheduling. Core Definitions

Quality of Service su Linux: Passato Presente e Futuro

Performance Comparison of RTOS

Exercises : Real-time Scheduling analysis

Least Slack Time Rate First: an Efficient Scheduling Algorithm for Pervasive Computing Environment

Real-Time Scheduling 1 / 39

Chapter 5 Process Scheduling

Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

Process Scheduling. Process Scheduler. Chapter 7. Context Switch. Scheduler. Selection Strategies

CPU Scheduling Outline

A Survey of Fitting Device-Driver Implementations into Real-Time Theoretical Schedulability Analysis

Homework 1 (Time, Synchronization and Global State) Points

How To Compare Real Time Scheduling To A Scheduled Scheduler On Linux On A Computer System With A Visualization System

Introduction. Scheduling. Types of scheduling. The basics

Scheduling Single Machine Scheduling. Tim Nieberg

Efficient Scheduling of Sporadic, Aperiodic, and Periodic Tasks with Complex Constraints

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Processor Scheduling. Queues Recall OS maintains various queues

Real-Time Task Scheduling for Energy-Aware Embedded Systems 1

AN APPROPRIATE ENGINEERING APPROACH

Attaining EDF Task Scheduling with O(1) Time Complexity

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

Partitioned EDF Scheduling for Multiprocessors using a C=D Scheme

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

Online Scheduling for Cloud Computing and Different Service Levels

A Constant-Approximate Feasibility Test for Multiprocessor Real-Time Scheduling

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

Global Multiprocessor Real-Time Scheduling as a Constraint Satisfaction Problem

Performance Analysis of Load Balancing Algorithms in Distributed System

Jorix kernel: real-time scheduling

Transcription:

Real-Time Scheduling (Part 1) (Working Draft) Insup Lee Department of Computer and Information Science School of Engineering and Applied Science University of Pennsylvania www.cis.upenn.edu/~lee/ CIS 41, Spring 20 Real-Time System Example Digital control systems periodically performs the following job: senses the system status and actuates the system according to its current status Control-Law Computation Sensor Actuator Spring CIS 41 2

Real-Time System Example Multimedia applications periodically performs the following job: reads, decompresses, and displays video and audio streams Multimedia Spring CIS 41 3 Scheduling Framework Example Digital Controller Multimedia OS Scheduler CPU Spring CIS 41 4

Fundamental Real-Time Issue To specify the timing constraints of real-time systems To achieve predictability on satisfying their timing constraints, possibly, with the existence of other real-time systems Spring CIS 41 Real-Time Spectrum No RT Soft RT Hard RT Computer simulation User interface Internet video, audio Cruise control Tele communication Flight control Electronic engine Spring CIS 41 6

Real-Time Workload Job (unit of work) o a computation, a file read, a message transmission, etc Attributes o Resources required to make progress o Timing parameters Released Execution time Absolute deadline Relative deadline Spring CIS 41 7 Real-Time Task Task : a sequence of similar jobs o Periodic task (p,e) Its jobs repeat regularly Period p = inter-release time (0 < p) Execution time e = maximum execution time (0 < e < p) Utilization U = e/p 0 1 Spring CIS 41 8

Schedulability Property indicating whether a real-time system (a set of real-time tasks) can meet their deadlines (,2) (7,2) Spring CIS 41 9 Real-Time Scheduling Determines the order of real-time task executions (,2) (7,2) 1 1 Spring CIS 41

Optimality Scheduling algorithm A is better than B if for every task set T, B can schedule T implies A can schedule T. Given a class C of scheduling algorithms, scheduling algorithm A is optimal in C, if A is better than every scheduling algorithm B in C. Spring CIS 41 11 Real-Time Scheduling Static scheduling o A fixed schedule is determined statically o E.g., Cyclic Executive Static-priority scheduling o Assign fixed priorities to processes o A scheduler only needs to know about priorities o E.g., Rate Monotonic (RM) Dynamic-priority scheduling o Assign priorities based on current state of the system o E.g., Least Completion Time (LCT), Earliest Deadline First (EDF), Least Slack Time (LST) Spring CIS 41 12

CYCLIC EXECUTIVE Spring CIS 41 13 Cyclic Executives A cyclic executive is a program that deterministically interleaves the execution of periodic tasks on a single processor. The order in which the tasks execute is defined by a cyclic schedule. Example: A = (, 1), B = (, 3), C = (1, 2), D = (30,8) (30, 3) (30, ) A B C D A B C A B D i i + i +1 i + 20 i +30 frame 1 frame 2 frame 3 A major cycle containing 3 frames Reference: The Cyclic executive model and ADA Proc. of RTSS, 1988, by Baker and Shaw Spring CIS 41 14

General structure of a major schedule major cycles i - 1 frames (minor cycles) i i + 1 idle frame overrun 1 2 3 4... t t + m t + 2m t + 3m t + 4m t + M correct timing enforced at the end of each frame Rules governing the choice of m for a given {(p i, e i, d i )} of n tasks o m d i, i = 1, 2,, n o m e i, i = 1, 2,, n o M/n = integer (m divides p i for at least one i ) o there must be at least one frame in the interval between the release time and deadline of every request. 2m - gcd (m, p i ) d i, for i = 1, 2,, n Spring CIS 41 1 Advantages of cyclic executive Simplicity and predictability: o timing constraints can be easily checked o the cyclic schedule can be represented by a table that is interpreted by the executive o context switching overhead is small o it is easy to construct schedules that satisfy precedence constraints & resource constraints without deadlock and unpredictable delay Spring CIS 41 16

Disadvantages Given major and frame times, structuring the tasks with parameters pi, ei, and di to meet all deadlines is NP-hard for one processor Splitting tasks into subtasks and determining the scheduling blocks of each task is time consuming Error in timing estimates may cause frame overrun: How to handle frame overrun? It is application dependent: o suspense or terminate the overrun task, and execute the schedule of the next frame o complete the suspended task as background later o complete the frame, defer the start of the next frame o log overruns. If too many overruns, do fault recovery Spring CIS 41 17 Mode changes Handling mode change is difficult. Mode change: deletion and addition of tasks or change the parameters of existing tasks When to do mode change? Pros and cons of doing it at the end of current frame, current major cycle, execution of the current task, upon interrupt immediately Handling sporadic tasks convert each sporadic task into a periodic one: periodic server (p, e, d) t m E d deadline min time between arrival too pessimistic - guarantees worst case p = min (t m, d - e +1) - performance by giving max time to the task set aside time in minor cycles for execution of sporadic tasks o does not guarantee worst case Spring CIS 41 18

Priority-driven algorithms A class of algorithms that never leave the processor(s) idle intentionally Also known as greedy algorithms and list algorithms Can be implemented as follows: (preemptive) o Assign priorities to tasks o Scheduling decisions are made when any task becomes ready, when a processor becomes idle, when the priorities of tasks change o At each scheduling decision time, the ready task with the highest priority is executed If non-preemptive, scheduling decisions are made only when a processor becomes idle. The algorithm is static if priorities are assigned to tasks once for all time, and is dynamic if they change. Static if fixed. Spring CIS 41 19 SCHEDULING ANOMALY Spring CIS 41 20

Example 3 0 6 2 4 4 non preemptive EDF, FIFO 11 14 0 3 9 13 missed deadline preemptive EDF 0 3 4 8 13 non preemptive, not priority-driven 0 3 4 8 14 intentional idle time Spring CIS 41 21 Unexpected behavior of priority-driven scheduling algorithm : 3 : 2 : 2 T 4 : 2 T 9 : 9 T : 4 T 6 : 4 T 7 : 4 T 8 : 4 L = (,,, T 4, T, T 6, T 7, T 8, T 9 ) P 1 T 9 P 2 T 4 T T 7 P 3 T 6 T 8 t Spring CIS 41 22

Unexpected behavior of priority-driven scheduling algorithm (cont.) Suppose that we have 4 processors: P 1 P 2 P 3 P 4 Suppose that execution times are 2, 1, 1, 1, 3, 3, 3, 3, 8 Suppose that T 4 before T and T 4 before T 6 are removed Spring CIS 41 23 Anomalies of Priority-Driven Systems Given J1, J2, J3, J4 Priority: o J1 > J2 > J3 > J4 Preemption but no job migration Two processors P1 and P2 Spring CIS 41 24

Cases: e2 = 6 and e2 = 2 Spring CIS 41 2 Cases: e2 = 3 and e2 = Spring CIS 41 26

Validation Problem Scheduling anomalies make validation hard Can anomalies exist even on single processor systems? Spring CIS 41 27 EARLIEST DEADLINE FIRST (EDF) Spring CIS 41 28

EDF (Earliest Deadline First) A task with a shorter deadline has a higher priority Executes a job with the earliest deadline Optimal dynamic priority scheduling for single processor (,2) (7,2) 1 1 Spring CIS 41 29 EDF (Earliest Deadline First) Executes a job with the earliest deadline (,2) (7,2) 1 1 Spring CIS 41 30

EDF (Earliest Deadline First) Executes a job with the earliest deadline (,2) (7,2) 1 1 Spring CIS 41 31 EDF (Earliest Deadline First) Executes a job with the earliest deadline (,2) (7,2) 1 1 Spring CIS 41 32

EDF (Earliest Deadline First) Optimal scheduling algorithm o if there is a schedule for a set of real-time tasks, EDF can schedule it. (,2) (7,2) 1 1 Spring CIS 41 33 Optimality of EDF Optimality of the earliest deadline first algorithm for preemptive scheduling on one processor Given a task system T, if the EDF algorithm fails to find a feasible schedule, then T has no feasible schedule, where o feasible schedule = one in which all release time and deadline constraints are met s deadline s deadline r 1, r 2 can always be transform to d 2 d 1 r 1, r 2 d 2 d 1 Spring CIS 41 34

Utilization Bounds Intuitively: o The lower the processor utilization, U, the easier it is to meet deadlines. o The higher the processor utilization, U, the more difficult it is to meet deadlines. Question: is there a threshold U bound such that o When U < U bound deadlines are met o When U > U bound deadlines are missed EDF Utilization Bound Real-time system is schedulable under EDF if and only if U i 1 Liu & Layland, Scheduling algorithms for multi-programming in a hard-real-time environment, Journal of ACM, 1973. Spring CIS 41 36

Schedulable Utilization Utilization of a periodic task (p, t, d) u = t/p the fraction of time the task keeps the processor busy U, total utilization of task system T = {(p i, t i, d i )} contains n tasks n U t i / p i demand for processor time A system i 1of n tasks with d i = p i can be feasibly scheduled if and only if U 1 o If U >1, the total demand of processor in the time interval [0, p 1 p 2 p n ] is p 2 p 3 p n t 1 + p 1 p 3 p n t 2 + p 1 p 2 p n-1 t n > p 1 p 2 p n clearly, no feasible schedule exists. o If U 1, the EDF algorithm can always find a feasible schedule. To show this statement is true, we suppose that the EDF algorithm fails to find a feasible schedule. And, then show U >1, which is a contradiction to U 1 Spring CIS 41 37 Processor Demand Bound Demand Bound Function : dbf(t) o the maximum processor demand by workload over any interval of length t t (,2) (7,2) 1 1 Spring CIS 41 38

EDF - Schedulability Analysis Real-time system is schedulable under EDF if and only if dbf(t) t for all interval t Baruah et al. Algorithms and complexity concerning the preemptive scheduling of periodic, real-time tasks on one processor, Journal of Real-Time Systems, 1990. Demand Bound Function : dbf(t) o the maximum processor demand by workload over any interval of length t Spring CIS 41 39 Behavior of earliest deadline algorithm Schedule (2, 1) (, 3) with U = 1.1 (2, 1) (, 3) Schedule (2, 0.8) (, 3.) with U = 1.1 (2, 0.8) (, 3.) Which deadline will be missed as U increases cannot be predicted Spring CIS 41 40

EDF Overload Conditions Domino effect during overload conditions o Example: (4,3), (,3), (6,3), T 4 (7,3) Deadline Miss! T 4 0 3 6 7 Better schedules : T 4 0 3 6 7 0 3 6 7 Spring CIS 41 41 RATE MONOTONIC (RM) Spring CIS 41 42

RM (Rate Monotonic) It assigns priority according to period A task with a shorter period has a higher priority Executes a job with the shortest period Optimal static-priority scheduling for single processor (,2) (7,2) 1 1 Spring CIS 41 43 RM (Rate Monotonic) Executes a job with the shortest period (,2) (7,2) 1 1 Spring CIS 41 44

RM (Rate Monotonic) Executes a job with the shortest period Deadline Miss! (,2) (7,2) 1 1 Spring CIS 41 4 RM Utilization Bound Real-time system is schedulable under RM if U i n (2 1/n -1) Liu & Layland, Scheduling algorithms for multi-programming in a hard-real-time environment, Journal of ACM, 1973. Spring CIS 41 46

Utilization RM Utilization Bound Real-time system is schedulable under RM if U i n (2 1/n -1) Example:, (,1), (,1), U i = 1/4 + 1/ + 1/ = 0. 3 (2 1/3-1) 0.78 Thus, {,, } is schedulable under RM. Spring CIS 41 47 RM Utilization Bound Real-time system is schedulable under RM if U i n (2 1/n -1) 1.1 1 0.9 0.8 0.7 0.6 0. RM Utilization Bounds 1 4 16 64 26 24 4096 The Number of Tasks Spring CIS 41 48

A Conceptual View of Schedulability Utilization i Ci P i Schedulable Unschedulable? Modified Question: is there a threshold U bound such that o When U < U bound deadlines are met o When U > U bound deadlines may or may not be missed Task Set Response Time Response time o Duration from released time to finish time (,2) (,2) 1 1 Spring CIS 41 0

Response Time Response time o Duration from released time to finish time Response Time (,2) (,2) 1 1 Spring CIS 41 1 Response Time Response Time (r i ) [Audsley et al., 1993] r i ei Tk HP( Ti) ri pk e k HP(T i ) : a set of higher-priority tasks than T i (,2) (,2) Spring CIS 41 2

RM - Schedulability Analysis Real-time system is schedulable under RM if and only if r i p i for all task T i (p i,e i ) Joseph & Pandya, Finding response times in a real-time system, The Computer Journal, 1986. Spring CIS 41 3 RM vs. EDF Rate Monotonic o Simpler implementation, even in systems without explicit support for timing constraints (periods, deadlines) o Predictability for the highest priority tasks EDF o Full processor utilization o Misbehavior during overload conditions For more details: Buttazzo, Rate monotonic vs. EDF: Judgement Day, EMSOF003. Spring CIS 41 4