Lecture Note #4: Task Scheduling (1) EECS 571 Principles of Real-Time Embedded Systems. Kang G. Shin EECS Department University of Michigan

Similar documents
ELC 4438: Embedded System Design Real-Time Scheduling

Real-Time and Embedded Systems (M) Lecture 4

3. Scheduling issues. Common approaches /2. Common approaches /1. Common approaches / /17 UniPD / T. Vardanega 06/03/2017

ENGG4420 CHAPTER 4 LECTURE 3 GENERALIZED TASK SCHEDULER

Lecture 6: Scheduling. Michael O Boyle Embedded Software

2. Scheduling issues. Common approaches /2. Common approaches /1. Common approaches / /18 UniPD - T. Vardanega 14/03/2018

Clock-Driven Scheduling

GENERALIZED TASK SCHEDULER

Clock-Driven Scheduling

Reference model of real-time systems

Priority-Driven Scheduling of Periodic Tasks. Why Focus on Uniprocessor Scheduling?

CHAPTER 4 CONTENT October :10 PM

Real-Time Systems. Modeling Real-Time Systems

Q1. What is Real time system? Explain the basic model of Real time system. (8)

Real Time Scheduling. Real Time Scheduling. Real-Time Scheduling. Scheduling

Tasks or processes attempt to control or react to external events occuring in real time RT processes must be able to keep up events

Lab: Response Time Analysis using FpsCalc Course: Real-Time Systems Period: Autumn 2015

CS510 Operating System Foundations. Jonathan Walpole

Lecture 11: Scheduling

DEADLINE MONOTONIC ALGORITHM (DMA)

Project 2 solution code

CPU Scheduling (Chapters 7-11)

Introduction to Real-Time Systems. Note: Slides are adopted from Lui Sha and Marco Caccamo

CPU scheduling. CPU Scheduling

Today s Papers. Composability is Essential. The Future is Parallel Software. EECS 262a Advanced Topics in Computer Systems Lecture 12

MAX PLANCK INSTITUTE FOR SOFTWARE SYSTEMS. Max Planck Institute for Software Systems (MPI-SWS) Germany

א א א א א א א א

Chapter 6: CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. CPU Scheduler. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Periodic task scheduling

CS 143A - Principles of Operating Systems

Real-Time Scheduling Theory and Ada

SE350: Operating Systems. Lecture 6: Scheduling

Scheduling theory, part 1

CSC 553 Operating Systems

CS 111. Operating Systems Peter Reiher

Design and Implementation of LST Based Dynamic Scheduler on Real Time OS

Adaptive Total Bandwidth Server: Using Predictive Execution Time

Scheduling issues in mixedcriticality

FIFO SJF STCF RR. Operating Systems. Minati De. Department of Mathematics, Indian Institute of Technology Delhi, India. Lecture 6: Scheduling

CPU Scheduling. Disclaimer: some slides are adopted from book authors and Dr. Kulkarni s slides with permission

Limited Preemptive Real-time Scheduling on Multiprocessors. Abhilash Thekkilakattil

CPU SCHEDULING. Scheduling Objectives. Outline. Basic Concepts. Enforcement of fairness in allocating resources to processes

CPU Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Unix Scheduler

Announcements. Program #1. Reading. Is on the web Additional info on elf file format is on the web. Chapter 6. CMSC 412 S02 (lect 5)

Motivation. Types of Scheduling

CSC 1600: Chapter 5. CPU Scheduling. Review of Process States

Limited-preemptive Earliest Deadline First Scheduling of Real-time Tasks on Multiprocessors

Mwave/OS: A Predictable Real-time DSP Operating System

Real time scheduling for embedded systems

CPU Scheduling. Chapter 9

Scheduling I. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Advanced topics on scheduling

Intro to O/S Scheduling. Intro to O/S Scheduling (continued)

Real-time System Overheads: a Literature Overview

Lecture 11: CPU Scheduling

Implementing a Predictable Real-Time. Multiprocessor Kernel { The Spring Kernel.

Dual Priority Algorithm to Schedule Real-Time Tasks in a Shared Memory Multiprocessor

Recall: Example of RR with Time Quantum = 20. Round-Robin Discussion

Advanced Types Of Scheduling

Rate Monotonic Analysis

Real-Time Scheduler Design For Embedded System Domain

Dual Priority Scheduling: A Means of Providing Flexibility in Hard Real-time Systems.

CPU Scheduling CPU. Basic Concepts. Basic Concepts. CPU Scheduler. Histogram of CPU-burst Times. Alternating Sequence of CPU and I/O Bursts

September 30 th, 2015 Prof. John Kubiatowicz

Principles of Operating Systems

A Reference Model of Real-Time Systems

Preference-Oriented Fixed-Priority Scheduling for Real-Time Systems

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

Introduction to Operating Systems. Process Scheduling. John Franco. Dept. of Electrical Engineering and Computing Systems University of Cincinnati

Chapter 9 Uniprocessor Scheduling

Scheduling Processes 11/6/16. Processes (refresher) Scheduling Processes The OS has to decide: Scheduler. Scheduling Policies

Scheduling II. To do. q Proportional-share scheduling q Multilevel-feedback queue q Multiprocessor scheduling q Next Time: Memory management

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - V CPU Scheduling - I. Louisiana State University.

Energy Efficient Fixed-Priority Scheduling for Real-Time Systems on Variable Voltage Processors

Learning Module II: Real-Time Systems Design

Slack Assessment of the Real Time Scheduling Algorithms

Technical Report CMU/SEI-89-TR-14 ESD-TR-89-; 022. Carnegie-Mellon University. Software Engineering Institute. Real-Time Scheduling Theory

Operating Systems. Scheduling

Schedulability Test for Soft Real-Time Systems under Multi- processor Environment by using an Earliest Deadline First Scheduling Algorithm Abstract

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - V CPU Scheduling - I. University at Buffalo.

CSE 5343/7343 Fall 2006 PROCESS SCHEDULING

Scheduling. CSE Computer Systems November 19, 2001

CSE 451: Operating Systems Spring Module 8 Scheduling

Recall: FCFS Scheduling (Cont.) Example continued: Suppose that processes arrive in order: P 2, P 3, P 1 Now, the Gantt chart for the schedule is:

Performance Comparison of RTS Scheduling Algorithms

Mode Change Protocols for Priority-Driven Preemptive Scheduling

Reading Reference: Textbook: Chapter 7. UNIX PROCESS SCHEDULING Tanzir Ahmed CSCE 313 Fall 2018

CPU Scheduling Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University

The BEST Desktop Soft Real-Time Scheduler

Co-scheduling Real-time Tasks and Non Real-time Tasks Using Empirical Probability Distribution of Execution Time Requirements.

Operating System 9 UNIPROCESSOR SCHEDULING

Course Outline. Embedded Real Time Operating System Chin Fu Kuo National University of Kaohsiung 2009 Fall

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

CPU Scheduling. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Asymptotic Analysis of Real-Time Queues

EEE499 - Real-Time Embedded System Design. Real-Time Schedulability Part I

Homework 2: Comparing Scheduling Algorithms

Comp 204: Computer Systems and Their Implementation. Lecture 10: Process Scheduling

CS 153 Design of Operating Systems Winter 2016

Graph Optimization Algorithms for Sun Grid Engine. Lev Markov

Transcription:

Lecture Note #4: Task Scheduling (1) EECS 571 Principles of Real-Time Embedded Systems Kang G. Shin EECS Department University of Michigan 1

Reading Assignment Liu and Layland s paper Chapter 3 of the text HW#2 has already been posted. 2

Main Question Will my real-time application really meet its timing constraints/requirements? Task Assignment and Scheduling: Given a set of tasks, precedence constraints, resource requirements, their execution times, release times, and deadlines, and a processing system, design a feasible/optimal allocation/scheduling of tasks on the processing system. Terminologies: feasibility, optimality, lateness, absolute/relative/effective deadlines, absolute/effective release times. 3

Components of Task Assigment & Scheduling Precedence relation (T) = the set of tasks that must be completed before task T can begin its execution Resource requirements: processor, memory, bus, disk,... Exclusive Shared (read-only, read-write) Schedule S: set of processors time set of tasks off-line or online static or dynamic priority alg preemptive or nonpreemtive uniprocessor or multiprocessor 4

Terminology Hard deadline: late result is of little or no value, or may lead to catastrophe need to guarantee it Soft deadline: late result may still be useful probability of missing deadlines With prob. 0.95 a telephone switch connects in 10 seconds How serious is serious? Tardiness: min{ 0, deadline - completion time} Utility: function of tardiness value completion time 5

Terminology: Temporal Parameters Release time: fixed (r), jitter [ r-δ, r+δ ], sporadic or aperiodic Execution time: Unpredictability due to memory refresh, contention due to DMA, pipelining, cache misses, interrupts, OS overhead Execution-path variations WCET: a deterministic parameter for the worst-case execution time a conservative measure an assumption to make scheduling and validation feasible how can you measure the WCET of a job? 6

Effective release time and deadline Release time of a job can be later than that of its successor Deadline of a job can be earlier than that of its predecessor Effective release time i = max {release time i, effective release times of all its precedessors} Effective release time = release time if no predecessor Effective deadline i = min {deadline i, deadlines of all its successors} Effective deadline = deadline if no successor 7

Classical Uniprocessor Scheduling Algorithms Rate Monotonic (RM): statically assign higher priorities to tasks with lower periods Deadline Monotonic (DM): the smaller relative deadline the higher priority. Earliest Deadline First (EDF): the earlier the deadline, the higher the priority; optimal if preemption is allowed and jobs do not contend for resources. Minimum-Laxity-First (MLF): the smaller the laxity the higher priority; optimal just like EDF. 8

Assumptions and Task Models for Classical Sched Algs Assumptions: Fully preemtable with negligible costs, Independent tasks, i.e., no precedence constraints between tasks CPU is the only resource to deal with. Task Model: Characterized by a subset of period/interarrival time, phase, execution time, absolute/effective release time, absolute/relative/effective deadline. Example: Periodic task T i = (φ i, P i, e i, d i ) = (phase, period, execution time, relative deadline) Task vs. job 9

More on Task model Periodic task T i : (examples?) constant (or bounded) period, p i : inter-release time between two consecutive jobs phase φ i, utilization u i = e i / p i, deadline (relative) D i Aperiodic and sporadic: (examples?) Sporadic: uncertain interarrival times but with a minimum separation and with a hard deadline aperiodic: non-periodic with no minimum separation and usually with a soft or no deadline e i D i φ i φ i +p i φ i +2p i φ i +3p i 10

Task Functional Parameters Preemptivity: suspend the executing job and switch to a different job should a job (or a portion of job) be preemptable context switch: save the current process status (PC, registers, etc.) and initiate a ready job Preemptivity of resources: concurrent use of resources or critical section lock, semaphore, disable interrupts How can a context switch be triggered? Assume you want to preempt an executing job, why? a higher priority job arrives Use up the assigned time quantum waiting wake-up ready blocked executing suspended dispatched 11

Task Scheduling Schedule: to determine which job is assigned to a processor at any given time valid schedule: satisfies constraints (release time, WCET, precedence constraints, etc.) feasible schedule: meet job deadlines Need an algorithm to generate a schedule optimal scheduling algorithm: can always find a feasible schedule if any other alg can Scheduler or dispatcher: the mechanism to implement a schedule Interaction between schedulers 12

Commonly-Used Real-Time Scheduling Approaches Clock-Driven: determines which job to execute when. All parameters of hard RT jobs are fixed and known; a schedule is computed off-line and stored for use at runtime. Weighted Round-Robin: for high-speed networks, where length of a round = sum of all weights. Priority-Driven: assigns priorities to jobs and executes jobs in priority order, Static priority assignment: Rate or Deadline Monotonic Dynamic priority assignment: Earliest Deadline First (EDF), Minimum Laxity First (MLF). 13

Clock-Driven Task Scheduling Clock-driven a schedule determines (off-line) which job to be executed at each instant static or cyclic predictable and deterministic scheduler: invoked by a timer multiple tables for different operation modes p 1 = 6, e 1 = 3, d 1 = 6 p 2 = 8, e 2 = 3, d 2 = 8 Major cycle = lcm (6,8) = 24 14

Clock-Driven RT Scheduling, cont d Time line is partitioned into frames, each with length f max 1 i n e i and f must also be a divisor of the planning (major) cycle, F= d L/f e. Scheduling decisions are made at the beginning of each frame, not within a frame. The first job of each task is released at the beginning of some frame. Cyclic executive: table-driven scheduler. Scheduling block L(k): names of job slices scheduled to execute within frame k. 15

Cyclic Executive Input: stored schedule: L(k) for k=0,1,l, F-1; /*F=# of frames per major cycle*/ Aperiodic job queue Task CYCLIC_EXECUTIVE: current time t=0; current frame k=0; do forever accept clock interrupt at time tf; currentblock = L(k); t := t+1; k:= t mod F; if the last job is not completed, take appropriate action; if any of the slices in currentblock is not released, take action; wake up the periodic server to execute the slices in current Block; sleep until the periodic server completes;/*completes periodic job slices*/ while the aperiodic job queue is nonempty, wake up the job at the head of the aperiodic queue; sleep until the aperiodic job completes: remove the aperiodic job from the queue: endwhile; sleep until the next clock interrupt; enddo; end CYCLIC_EXECUTIVE 16

Round-Robin Task Scheduling Weighted Round-robin interleave job executions allocate a time slice to each job in the FIFO queue time slice may vary while sharing the processor good for pipelined jobs, e.g., network packets p 1 = 6, e 1 = 3, d 1 = 6 p 2 = 8, e 2 = 3, d 2 = 8 Major/planning cycle = LCM (6,8) = 24 17

Priority-Driven Task Scheduling Priority-driven The highest-priority job gets to run until completion or blocked A processor is never idle if ready jobs are waiting (work-conserving) preemptive or non-preemptive priority assignment can be static or dynamic Scheduler just looks at the priority queue for waiting jobs (list schedule) p 1 = 6, e 1 = 3, d 1 = 6 p 2 = 8, e 2 = 3, d 2 = 8 Major cycle = lcm (6,8) = 24 18

Earliest-Deadline-First (EDF) Schedule Preemptive dynamic priority scheduling a job with earliest (absolute) deadline has the highest priority does not require the knowledge of execution time Optimal if single processor, no resource contention, preemptive why is this optimal? assume a feasible schedule J i J k (non-edf) d k d i r k J k J k J i (EDF) d k d i 19

Least Slack Time (LST) Schedule Preemptive priorityscheduling based on slack time (d i -e i* ) schedule instants: when jobs are released or completed. optimal for preemptive single processor schedule J 1 J 2 J 3 Slack time LST 20

Non-optimality of EDF Non-preemptive or multiple processors scheduling anomaly --- the schedule fails even after we reduce job execution times D 1 D 2 D 3 T 1 T 2 T 3 Missed deadline idle ( all jobs meet their deadline under EDF after increasing e 1 ) 21

Predictable System With variant job execution times, do we know when a task is started or completed? If the start & completion times and the deadline are known, then we can determine whether a schedule is feasible or not Two extreme conditions: maximal schedule: all jobs take their maximal execution times minimal schedule: all jobs take their minimal execution times A job is predictable iff its start and complete times are predictable: s - ( J i ) s ( J i ) s + ( J i ) f - ( J i ) f ( J i ) f + ( J i ) The execution of every job in a set of independent, preemptive jobs with fixed release times is predictable when scheduled in a priority-driven manner on a single processor 22

On-line vs. Off-line Scheduling Off-line scheduling: the schedule is computed off-line and is based on the knowledge of the release times and execution times of all jobs. A system with fixed sets of functions and job characteristics does not vary or vary only slightly. On-line scheduling: a scheduler makes each scheduling decision without knowledge about the jobs that will be released in future. there is no optimal on-line schedule if jobs are non-preemptive when a job is released, the system can serve it, or wait for future jobs J 2 J 1 ( should wait for J 2 ) r 1 r 2 D 2 D 1 J 1 J 3 ( should begin J 1 ) r 1 r 3 D 1 and D 3 23

Aperiodic Tasks A periodic server follows the cyclic schedule A aperiodic server looks at the aperiodic task queue runs at the background Slack stealing slack time: how much each periodic task can be delayed Assume all tasks must be completed before the end of their frames and aperiodic tasks are not preemptable at frame k, e k is allocated to periodic tasks slack time: s= f - e k at the beginning of frame k, find an aperiodic task j with an execution time e j that is less than s try to run the other aperiodic task with a slack time: s=s - e j Do slack stealing at the beginning of each frame and then examine the queue when idle 24

Sporadic Tasks Accept if the sporadic task can be done before its deadline If more than one sporadic task EDF Assume tasks are preemptable (run across frame boundary) When a sporadic task arrives ---- schedule it immediately or at the beginning of the next frame is there enough slack time before its deadline and for every existing sporadic task Bookkeeping slack time from frame i to l: σ(i,l), l=1,2,3,, F for each sporadic task, remaining execution time and slack time Let the deadline of an arriving task is in frame l+1 is there enough slack time for all tasks with a deadline before frame l+1? for each task with a deadline later than frame l+1, can it be delayed by the new arrival? 25

Sporadic Tasks -- Example 3.5 3 2 3 3 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 A table of σ(i,l), i,l=1,2,3,, F Assume S1(17,4.5) arrives at time 3 --- checks at time 4 S2(29,4) arrives at time 5 S3(22,1.5) arrives at time 11 S4(44,5.0) arrives at time 14 26

Pros Summary of Cyclic Schedule simple, table-driven, easy to validate (knows what is doing at any moment) fits well for harmonic periods and small system variations static schedule deterministic, static resource allocation, no preemption small jitter no scheduling anomalies Cons difficult to change (need to re-schedule all tasks) fixed released times for the set of tasks difficult to deal with different temporal dependencies schedule algorithm may get complex (NP-hard) doesn t support aperiodic and sporadic tasks efficiently 27