Real-time operating systems course. 6 Definitions Non real-time scheduling algorithms Real-time scheduling algorithm

Similar documents
CPU SCHEDULING RONG ZHENG

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CSE 380 Computer Operating Systems

Module 5: CPU Scheduling

Comp 204: Computer Systems and Their Implementation. Lecture 11: Scheduling cont d

Chapter 6: CPU Scheduling

Scheduling. Uwe R. Zimmer & Alistair Rendell The Australian National University

CPU scheduling. CPU Scheduling

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CPU Scheduling. Heechul Yun

TDDI04, K. Arvidsson, IDA, Linköpings universitet CPU Scheduling. Overview: CPU Scheduling. [SGG7] Chapter 5. Basic Concepts.

CHAPTER 5 - PROCESS SCHEDULING

Embedded Systems 14. Overview of embedded systems design

2/5/07 CSE 30341: Operating Systems Principles

Process Scheduling. Process Scheduling. CPU and I/O Bursts. CPU - I/O Burst Cycle. Variations in Bursts. Histogram of CPU Burst Times

Real-Time Systems. Event-Driven Scheduling

Task Models and Scheduling

CPU Scheduling Exercises

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

Simulation of Process Scheduling Algorithms

CPU Scheduling. CPU Scheduler

Networked Embedded Systems WS 2016/17

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

LSN 15 Processor Scheduling

UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

CS 550 Operating Systems Spring CPU scheduling I

Embedded Systems 15. REVIEW: Aperiodic scheduling. C i J i 0 a i s i f i d i

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II

Last class: Today: Threads. CPU Scheduling

CIS 4930/6930: Principles of Cyber-Physical Systems

Real-Time Systems. Event-Driven Scheduling

Aperiodic Task Scheduling

Lecture 13. Real-Time Scheduling. Daniel Kästner AbsInt GmbH 2013

Lecture 6. Real-Time Systems. Dynamic Priority Scheduling

Scheduling Lecture 1: Scheduling on One Machine

DETERMINING THE VARIABLE QUANTUM TIME (VQT) IN ROUND ROBIN AND IT S IMPORTANCE OVER AVERAGE QUANTUM TIME METHOD

Embedded Systems Development

Scheduling Lecture 1: Scheduling on One Machine

CS 370. FCFS, SJF and Round Robin. Yashwanth Virupaksha and Abhishek Yeluri

ENHANCING CPU PERFORMANCE USING SUBCONTRARY MEAN DYNAMIC ROUND ROBIN (SMDRR) SCHEDULING ALGORITHM

Real-Time Scheduling and Resource Management

3. Scheduling issues. Common approaches 3. Common approaches 1. Preemption vs. non preemption. Common approaches 2. Further definitions

Half Life Variable Quantum Time Round Robin (HLVQTRR)

Real-Time and Embedded Systems (M) Lecture 5

Improvising Round Robin Process Scheduling through Dynamic Time Quantum Estimation

Process Scheduling for RTS. RTS Scheduling Approach. Cyclic Executive Approach

Real-Time Systems. Lecture 4. Scheduling basics. Task scheduling - basic taxonomy Basic scheduling techniques Static cyclic scheduling

Design and Performance Evaluation of a New Proposed Shortest Remaining Burst Round Robin (SRBRR) Scheduling Algorithm

Embedded Systems - FS 2018

Journal of Global Research in Computer Science

Clock-driven scheduling

There are three priority driven approaches that we will look at

Non-preemptive Fixed Priority Scheduling of Hard Real-Time Periodic Tasks

Dynamic Time Quantum based Round Robin CPU Scheduling Algorithm

Revamped Round Robin Scheduling Algorithm

ODSA: A Novel Ordering Divisional Scheduling Algorithm for Modern Operating Systems

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

Andrew Morton University of Waterloo Canada

Non-Preemptive and Limited Preemptive Scheduling. LS 12, TU Dortmund

COMPARATIVE PERFORMANCE ANALYSIS OF MULTI-DYNAMIC TIME QUANTUM ROUND ROBIN (MDTQRR) ALGORITHM WITH ARRIVAL TIME

Season Finale: Which one is better?

Scheduling IoT on to the Cloud : A New Algorithm

Priority-driven Scheduling of Periodic Tasks (1) Advanced Operating Systems (M) Lecture 4

Journal of Global Research in Computer Science

Real-Time Systems. LS 12, TU Dortmund

Efficient Dual Nature Round Robin CPU Scheduling Algorithm: A Comparative Analysis

RUN-TIME EFFICIENT FEASIBILITY ANALYSIS OF UNI-PROCESSOR SYSTEMS WITH STATIC PRIORITIES

A Theory of Rate-Based Execution. A Theory of Rate-Based Execution

EDF Feasibility and Hardware Accelerators

A NEW PROPOSED DYNAMIC DUAL PROCESSOR BASED CPU SCHEDULING ALGORITHM

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

Real-Time Scheduling

February 2011 Page 23 of 93 ISSN

Simple Dispatch Rules

An Improved Round Robin Approach using Dynamic Time Quantum for Improving Average Waiting Time

EDF Scheduling. Giuseppe Lipari May 11, Scuola Superiore Sant Anna Pisa

Cyclic Schedules: General Structure. Frame Size Constraints

Scheduling Algorithms for Multiprogramming in a Hard Realtime Environment

PBS: A Unified Priority-Based CPU Scheduler

EDF Scheduling. Giuseppe Lipari CRIStAL - Université de Lille 1. October 4, 2015

NATCOR: Stochastic Modelling

Paper Presentation. Amo Guangmo Tong. University of Taxes at Dallas January 24, 2014

Dependency Graph Approach for Multiprocessor Real-Time Synchronization. TU Dortmund, Germany

Minimizing the Number of Tardy Jobs

A new Hybridized Multilevel Feedback Queue Scheduling with Intelligent Time Slice and its Performance Analysis

ENHANCING THE CPU PERFORMANCE USING A MODIFIED MEAN- DEVIATION ROUND ROBIN SCHEDULING ALGORITHM FOR REAL TIME SYSTEMS.

A Dynamic Real-time Scheduling Algorithm for Reduced Energy Consumption

Real-Time Systems. Lecture #14. Risat Pathan. Department of Computer Science and Engineering Chalmers University of Technology

The Concurrent Consideration of Uncertainty in WCETs and Processor Speeds in Mixed Criticality Systems

System Model. Real-Time systems. Giuseppe Lipari. Scuola Superiore Sant Anna Pisa -Italy

Determining the Optimum Time Quantum Value in Round Robin Process Scheduling Method

A 2-Approximation Algorithm for Scheduling Parallel and Time-Sensitive Applications to Maximize Total Accrued Utility Value

Optimal Utilization Bounds for the Fixed-priority Scheduling of Periodic Task Systems on Identical Multiprocessors. Sanjoy K.

Non-Work-Conserving Non-Preemptive Scheduling: Motivations, Challenges, and Potential Solutions

Real-Time Scheduling. Real Time Operating Systems and Middleware. Luca Abeni

Schedulability analysis of global Deadline-Monotonic scheduling

A Framework for Automated Competitive Analysis of On-line Scheduling of Firm-Deadline Tasks

An Improved Schedulability Test for Uniprocessor. Periodic Task Systems

International Journal of Advanced Research in Computer Science and Software Engineering

Online Energy-Aware I/O Device Scheduling for Hard Real-Time Systems with Shared Resources

Transcription:

Real-time operating systems course 6 Definitions Non real-time scheduling algorithms Real-time scheduling algorithm

Definitions

Scheduling Scheduling is the activity of selecting which process/thread should be executed next In general operating systems, we can distinguish 3 types of scheduling Long term scheduling before creating a process, decide if it must be activated Medium term scheduling decide if a process has to be swapped out/in Short term scheduling decide which process has to be executed next 3

Scheduling long-term scheduling new long-term scheduling ready/ suspend medium-term scheduling ready short-term scheduling running blocked/ suspend medium-term scheduling blocked 4

Long-term scheduling When a program is created, it goes through an admission test If the program is admitted, the process is created and put into the ready queue If the program is not admitted, it is held back, until the multiprogramming level allows the process to start The key decision is the multiprogramming level if the multiprogramming level is too high, each process executes too slowly, and we risk the thrashing so we can hold back the new processes until the load is decreased 5

Medium-term scheduling It is the part of the OS that decides with processes to swap-in and out it has to do with the multiprogramming level! it has been already discussed in the previous part 6

Short-term scheduling We distinguish Selection function: decides which process is selected from the ready queue, according to some rule Decision mode: when the decision is taken Non-preemptive: once the process goes into running state, no scheduling decision can be taken until it finishes Preemptive: periodically (like in round-robin) when a new process is created when a process in unblocked when an interrupt arrives 7

Scheduling criteria How to evaluate a scheduler? User-oriented criteria response time of processes System-oriented criteria throughput: how much work the system can do in any interval of time Performance is important but not only! in some case we may want some other criteria, predictability (see real-time systems) fairness 8

CPU-Bound and I/O bound CPU-bound processes perform very little I/O operations Most of the time, they execute on the processor For example, the gcc compiler, a scientific computation program,... I/O bound processes perform many I/O operations Most of the time, they are blocked waiting for an I/O device For example, The find and grep commands, the disk de-fragmenter Most processes are a mixture of both 9

Definitions A schedule is said to be feasible if all the tasks are able to complete within a set of constraints. A set of tasks is said to be schedulable if there exists a feasible schedule for it. 10

The general scheduling problem Given a set of n tasks, a set P of m processors, and a set R of r resources, find an assignment of P and R to which produces a feasible schedule. P R Scheduling algorithm feasible 11

Complexity In 1975, Garey and Johnson showed that the general scheduling problem is NP hard. However, polynomial time algorithms can be found under particular conditions. 12

Complexity It is important to find polynomial time algorithms number of tasks = 30 elementary step = 1 s alg. 1: O(log n) 2 alg. 2: O(n) alg. 3: O(n 6 ) alg. 4: O(6 n ) ~6 s 30 s 12 min 7 billion of years 13

Simplifying assumptions Single processor Fully preemptive tasks Simultaneous activations No precedence constraints No resource constraints 14

Algorithm taxonomy preemptive vs. non preemptive off line vs. on line static vs. dynamic best effort vs. optimal 15

Off-line vs. On-line Off-line all scheduling decisions are taken before task activation: the schedule is stored in a table (table-driven scheduling). On-line scheduling decisions are taken at run time on the set of active tasks. 16

static vs. dynamic static scheduling decisions are taken based on fixed parameters, statically assigned to tasks before activation dynamic scheduling decisions are taken based on parameters that can change with time 17

optimal vs. best-effort optimal Always find a feasible schedule, if there exists one. best-effort do their best to find a feasible schedule, if there exists one, but they do not guarantee that. 18

non real-time scheduling algorithms

classical scheduling policies First Come First Served (FCFS) Shortest Job First (SJF) Priority Scheduling Round Robin (RR) not suited for real-time systems 20

First Come First Served (FCFS) It assigns the CPU to tasks based on their arrival times. READY queue CPU non preemptive t dynamic on line best effort 21

First Come First Served (FCFS) (2) very unpredictable response times strongly depend on task arrivals. r 1 r 2 r 3 R 1 = 20 R 2 = 26 R 3 = 26 1 2 3 0 4 8 12 16 20 24 28 32 r 3 r 2 r 1 R 1 = 26 R 2 = 8 R 3 = 2 3 2 1 0 4 8 12 16 20 24 28 32 t t 22

Shortest Job First (SJF) it selects the task with the shortest computation time. non preemptive or preemptive static (C i is a constant parameter) it can be used on line or off-line it minimizes the average response time 23

SJF optimality SJF L S r 0 S L f S < f L f L = f S t f S + f L f S + f L n R '= 1 n i =1 f ' i r i 1 n i=1 n f i r i =R 24 24

SJF optimality (2) *... RR ' R ' ' R * = SJF R SJF is the minimum average response time achievable by any algorithm 25 25

SJF suited for Real-Time? it is not optimal in the sense of feasibility A SJF feasible d 1 d 2 d 3 1 2 0 4 8 12 16 20 24 28 32 3 t SJF not feasible d 1 d 2 d 3 3 2 1 0 4 8 12 16 20 24 28 32 t 26

priority scheduling each task is assigned a priority example, pi [0, 255] the task with the highest priority is selected for execution. tasks with the same priority are served FCFS or RR. can be used for real-time purposes if priorities are assigned following specific rules the POSIX scheduler is a priority scheduler with 32 priorities static or dynamic 27

priority scheduling problem: starvation low priority tasks may experience long delays due to the preemption of high priority tasks. a solution: aging priority increases with waiting time NOTE: p i 1/C i SJF p i 1/r i FCFS 28

round robin the ready queue is served as FCFS, but... the system has a concept of time quantum (Q). each task i cannot execute more than Q time units when Q expires, i is put back in the queue. READY queue CPU Q expired 29

round robin (2) n = number of tasks in the system nq nq t Q time sharing R i nq C i Q =nc i each task runs as it was executing alone on a virtual processor n times slower than the real one. 30

round robin (3) if Q > max (Ci) then RR FCFS if Q context switch time (δ) then n(q + δ) n(q + δ) t Q + δ R i nq C i i Q =nc Q Q 31

priority - based RQ0 running admit RQ1 RQ2 preemption RQn 32

multiple-feedback queues this scheduler consists of N queues, RQ 0,..., RQ N each queue is ordered in FIFO order a fixed time quantum Q (like in Round Robin) rules 1. the scheduler chooses the first process in the highest priority queue and sets the timer equal to Q. Let RQ k be the highest priority queue that has some task ready to execute 2. if the process completes or blocks before the timer expires, select the next process (go to 1) 3. if the process has not yet completed by Q, move the process to the next queue RQ (k+1) 4. when a process is activated or it is unblocked, it goes in the highest priority queue RQ 0 5. periodically, processes can be moved up if they were not able to execute enough (to avoid starvation) 33

multiple-feedback queues (2) this scheduling policy tries to overcome the penalty for I/O bound processes a process always starts from RQ 0 a short process, will probably complete very soon an I/O-bound process is always executed with very short delay a long CPU-bound eventually goes in the last queue RQ N if the system is heavily loaded, periodically the CPU-bound processes in the last queue are promoted to higher priority queues 34

real-time scheduling algorithms

Real-Time algorithms tasks can be scheduled by relative deadlines D i (static) absolute deadlines d i (dynamic) D i d i 36

Earliest Due Date it selects the task with the earliest relative deadline [Jackson 55]. all tasks arrive simultaneously fixed priority (D i is known in advance) preemption is not an issue it minimizes the maximum lateness (L max ) 37

lateness L i = f i - d i L i > 0 r i d i L i < 0 f i r i f i d i 38

maximum lateness L max = max i (L i ) if (L max < 0) then no task misses its deadline 39

EDD Optimality EDD B A A r 0 d a d b B t f a < f a f b = f a L max = L a = f a - d a L a = f a - d a < f a - d a L b = f b - d b = f a - d b < f a - d a L max < L max 40 40

EDD Optimality *... L max L max ' L max ' 'L max * = EDD L max EDD is the minimum value achievable by any algorithm 41

EDD - guarantee test (off line) 1 2 3 4 t f 1 f 2 f 3 f 4 a task set is feasible if i f i d i i f = i k=1 i C k i k =1 C k D i 42

Earliest Deadline First (EDF) it selects the task with the earliest absolute deadline [Horn 74] tasks may arrive at any time dynamic priority (d i depends on arrival) fully preemptive tasks it minimizes the maximum lateness (L max ) 43

EDF example 44

EDF Guarantee test (on line) c 1 (t) c 2 (t) c 3 (t) c 4 (t) t i i k =1 c k td i t 45

complexity issues EDD EDF O(n log n) to order the task set O(n) to guarantee the whole task set O(n) to insert a new task in the queue O(n) to guarantee a new task 46