GENERALIZED TASK SCHEDULER

Similar documents
ENGG4420 CHAPTER 4 LECTURE 3 GENERALIZED TASK SCHEDULER

CHAPTER 4 CONTENT October :10 PM

ELC 4438: Embedded System Design Real-Time Scheduling

Clock-Driven Scheduling

DEADLINE MONOTONIC ALGORITHM (DMA)

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

Real-Time and Embedded Systems (M) Lecture 4

Clock-Driven Scheduling

Lecture 6: Scheduling. Michael O Boyle Embedded Software

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

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

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

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

א א א א א א א א

CS510 Operating System Foundations. Jonathan Walpole

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

CPU Scheduling. Chapter 9

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

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

CPU scheduling. CPU Scheduling

CS 111. Operating Systems Peter Reiher

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

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

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

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

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

Project 2 solution code

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

Lecture 11: Scheduling

Operating System 9 UNIPROCESSOR SCHEDULING

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

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

Real-Time Systems. Modeling Real-Time Systems

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

CS 143A - Principles of Operating Systems

CSC 553 Operating Systems

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

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

CSE 5343/7343 Fall 2006 PROCESS SCHEDULING

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

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

Uniprocessor Scheduling

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

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

Principles of Operating Systems

Rate Monotonic Analysis

Chapter 9 Uniprocessor Scheduling

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

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

Advanced Types Of Scheduling

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

CPU Scheduling: Part I. Operating Systems. Spring CS5212

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

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

SE350: Operating Systems. Lecture 6: Scheduling

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

Reference model of real-time systems

Lecture 11: CPU Scheduling

CPU Scheduling (Chapters 7-11)

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

Scheduling Algorithms. Jay Kothari CS 370: Operating Systems July 9, 2008

Real-Time Scheduler Design For Embedded System Domain

Simulation of Process Scheduling Algorithms

CSE 451: Operating Systems Spring Module 8 Scheduling

Performance Comparison of RTS Scheduling Algorithms

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

The Design of SMART: A Scheduler for Multimedia Applications

Real-Time Scheduling Theory and Ada

Salisu Aliyu Department of Mathematics, Ahmadu Bello University, Zaria, Nigeria

Operating Systems. Scheduling

SCHEDULING AND CONTROLLING PRODUCTION ACTIVITIES

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

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

CPU Scheduling. Jo, Heeseung

Scheduling theory, part 1

Real-time System Overheads: a Literature Overview

Scheduling issues in mixedcriticality

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

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

CPU Scheduling. Jo, Heeseung

CRITICAL TASK RE-ASSIGNMENT UNDER HYBRID SCHEDULING APPROACH IN MULTIPROCESSOR REAL- TIME SYSTEMS

September 30 th, 2015 Prof. John Kubiatowicz

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

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

Chapter 3: Planning and Scheduling Lesson Plan

Implementation and Evaluation of Multi-Mode Real-Time Tasks under Different Scheduling Algorithms

APPENDIX 1 Processing time (pij) Release date (rj) Due date (dj): Weight (wj)

Bounding Worst-Case Response Time for Tasks With Non-Preemptive Regions

CS 153 Design of Operating Systems Winter 2016

Exploiting Dynamic Workload Variation in Low Energy Preemptive Task Scheduling

Slack Assessment of the Real Time Scheduling Algorithms

1

Timed/Advance Reservation Schemes and Scheduling Algorithms for QoS Resource Management in Grids

Periodic task scheduling

Lecture 3. Questions? Friday, January 14 CS 470 Operating Systems - Lecture 3 1

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

Adaptive Total Bandwidth Server: Using Predictive Execution Time

Transcription:

CHAPTER 4 By Radu Muresan University of Guelph Page 1 ENGG4420 CHAPTER 4 LECTURE 4 November 12 09 2:49 PM GENERALIZED TASK SCHEDULER In practical applications we need to be able to schedule a mixture of periodic, aperiodic, and sporadic tasks. Assigning aperiodic and sporadic tasks to frames will affect the overall achievable utilization factor of the system. In a generalized scheduler, initially a schedule only for periodic tasks is developed; the sporadic and aperiodic tasks are scheduled in the slack time available in the frames. Slack time in a frame is the time left after the periodic tasks allocated to the frame complete. An arriving sporadic task is taken for scheduling only if enough slack time is available the task to complete before its deadline => acceptance test upon its arrival Aperiodic task do not have strict deadline The best effort can be made to schedule them in the available slack no guarantee for meeting deadlines. EFFICIENT IMPLEMETATION slack times for all frames are stored in a table and during acceptance test this table is used to check schedulability of the arriving tasks POPULAR ALTERNATIVE all sporadic and aperiodic tasks are accepted and best effort is made to meet their deadlines

CHAPTER 4 By Radu Muresan University of Guelph Page 2 PSEUDO CODE FOR A GENERALIZED SCHEDULER The generalized scheduler below schedules periodic, aperiodic, and sporadic tasks; it is assumed that the precomputed schedule for periodic tasks is stored in a schedulable table, and the sporadic tasks have been subjected to an acceptance test and only the tasks that have passed the test are available for scheduling cyclic-scheduler( ) { current-task T = Schedule-Table [k]; k = k + 1; //N is the total number of tasks k = k mod N; //in the schedule table dispatch-current-task (T); schedule-sporadic-tasks( ); //current task T //completed early, sporadic task can be taken schedule-aperiodic-tasks ( ); //at the end of the //frame, the running task is preempted, //if not complete idle ( ); //no task to run, idle } The cyclic scheduler routine cyclic scheduler() is activated at the end of every frame by a periodic timer

CHAPTER 4 By Radu Muresan University of Guelph Page 3 COMPARISON OF CYCLIC AND TABLE DRIVEN SCHEDULING A cyclic scheduler needs to set a periodic timer only once at the application initialization time; this timer continues to give an interrupt exactly at every frame boundary. In a table driven scheduling, a timer has to be set every time a task starts to run; the execution time of a typical real time task is usually of the order of a few milliseconds => a call to a timer is made every few milliseconds => degraded system performance. A CYCLIC SCHEDULER IS MORE EFFICIENT THAN A TABLE DRIVEN SCHEDULER If the overhead of setting a timer can be ignored A TABLE DRIVEN SCHEDULER IS MORE PROFICIENT than a cyclic scheduler because: The frame size must be chosen to be greater than the largest execution time of a task => processor time can be wasted when we execute tasks that have their execution times smaller than the frame size.

CHAPTER 4 By Radu Muresan University of Guelph Page 4 HYBRID SCHEDULERS In hybrid schedulers, the scheduling points are defined both through the clock interrupts and the event occurrences. Time-Sliced Round-Robin Scheduling Also, called processor-sharing algorithm Round-robin approach is used for scheduling time-shared applications jobs entering the queue FIFO Queue n n-1 3 2 1 the job at the head of the queue enters execution for at most one time slice preempted Scheduling Algorithm ti time slice (xx ms) t1 t2 tn Job Completion Round period = n*t Where: n - number of jobs and t - time slice 1/n processor share/job ENGG4420: Real-Time Systems Design; Developed by Radu Muresan; Fall 2006 28 Time sliced round robin schedulers are commonly used in the traditional operating systems. A time sliced round robin scheduler is less proficient than table driven or cyclic scheduler This type of scheduler treats all task equally, and all tasks are assigned identical time slices irrespective of their priority, criticality, or closeness to their deadline. We can extend the round robins scheme and assign weights to tasks.

CHAPTER 4 By Radu Muresan University of Guelph Page 5 Weighted Round-Robin Approach WRR has been used for scheduling real-time traffic in high-speed switched networks jobs entering the queue FIFO Queue n n-1 3 2 1 the job at the head of the queue enters execution for wt slices preempted Scheduling Algorithm t time slice (xx ms) w 1 t w 2 t w n t Job Completion Round length = (wi*t) ENGG4420: Real-Time Systems Design; Developed by Radu Muresan 29 The weighted round robin algorithm has been used for scheduling real time traffic in high speed switched networks. Rather than giving all the ready jobs equal shares of the processor, different jobs may be given different weights. Here, the weight of a job refers to the fraction of processor time allocated to the job. Specifically, a job with weight w gets w*t time slices every round, and the length of a round is equal to the sum of the weights of all the ready jobs. By adjusting the weights of the jobs, we can speed up or retard the progress of each job toward its completion.

CHAPTER 4 By Radu Muresan University of Guelph Page 6 EVENT DRIVEN SCHEDULING November 13 09 6:33 PM SHORTCOMINGS OF CYCLIC SCHEDULERS Difficult to determine a suitable frame size as well as a feasible schedule when the number of tasks is large In almost every frame some processing time is wasted (as the frame size is larger than all task execution times) resulting in sub optimal schedules Reduced proficiency in handling sporadic and aperiodic tasks EVENT DRIVEN SCHEDULERS overcome these shortcomings, however they are less efficient as they deploy more complex scheduling algorithms => eventdriven schedulers are less suitable for embedded applications as they required to be of small size, low cost, and consume minimal amount of power. In event driven schedulers, the scheduling points are defined by tasks completion and task arrival events These class of schedulers are normally preemptive, that is, a higher priority task when ready, preempts any lower priority task that may be running WE DISCUSS 3 important examples of event driven schedulers: 1) foreground background; 2) EDF; 3) RMA

CHAPTER 4 By Radu Muresan University of Guelph Page 7 Priority-Driven Approach (Event-Driven) The term priority-driven algorithms refers to a large class of scheduling algorithms that never leave any resources idle intentionally Priority-driven algorithms are event-driven scheduling decisions are made when events such as release and completions of jobs occur A priority-driven algorithm is greedy because it tries to make locally optimal decisions A priority-driven algorithm is list scheduling because any prioritydriven algorithm can be implemented by assigning priorities to jobs greedy scheduling Resource Availability Data List of Priorities Queues list scheduling Releases and Completions of Jobs Events Priority Driven Scheduling Algorithms ENGG4420: Real-Time Systems Design; Developed by Radu Muresan 31 A resource (processor or other type) idles only when no job requiring the resource is ready for execution. Scheduling decisions are made when events such a release and completions of jobs occur. Hence, priority driven algorithm are event driven. Other commonly used names for this approach are greedy scheduling, list scheduling and work conserving scheduling. A priority driven algorithm is greedy because it tries to make locally optimal decisions. Leaving a processor or resource idle while some job is ready to use them is not locally optimal. However, sometimes it is better to have some jobs wait even when they are ready to execute and the resources they require are available. The term list scheduling implies assigning priorities to jobs. Jobs ready for execution are placed in one or more queues ordered by the priorities of the jobs. At any scheduling decision time, the jobs with the highest priorities are scheduled and executed on the available processors. Hence, a prioritydriven scheduling algorithm is defined to a great extent by the list of priorities it assigns to jobs; the priority list and other rules, such as whether preemption is allowed, define scheduling algorithm completely. Most scheduling algorithms used in non real time systems are priority driven. Examples include: FIFO (First In First Out), LIFO (Last In First Out) which assign priorities to jobs according to their release time; SETF (Shortest Execution Time First) and LEFT (Longest Execution Time First), which are algorithm that assign priorities based on the basis of job execution time.

CHAPTER 4 By Radu Muresan University of Guelph Page 8 Example of Priority-Driven Approach Schedule and execute the jobs J1,, J8 on 2 processors with shared memory Task graph: Ji, k i job number k execution time J5 released at 4; all other jobs at time 0 Priority list J i > J k if i < k (a) jobs are preemptable (b) jobs are nonpreemptable J 1,3 J 2,1 J 3,2 J 4,2 J 5,2 J 6,4 (J 1, J 2,,J 8 ) J 7,4 J 8,1 Priority list P 1 J 1 J 4 J 7 J 6 0 1 2 3 4 5 6 7 8 9 10 11 12 P 2 J 2 J 3 J 7 J 5 J 8 0 1 2 3 4 5 6 7 8 9 10 11 12 J 4 J 5 J 6 P 1 J 1 0 1 2 3 4 5 6 7 8 9 10 11 12 P 2 J 2 J 3 J 7 J 8 0 1 2 3 4 5 6 7 8 9 10 11 12 ENGG4420: Real-Time Systems Design; Developed by Radu Muresan 33 (a) (b) All edges in the task graph shown represent precedence constraints. The priority list is given next to the graph: Ji has a higher priority than Jk if i < k. All the jobs are preemptable; scheduling decisions are made whenever some job becomes ready for execution or some job completes. Schedule (a) shows the schedule of jobs on the two processors generated by the priority driven algorithm following this priority assignment. At time 0, jobs J1, J2, and J7 are ready for execution. They are the only jobs in the common priority queue at this time. J1 and J2 are scheduled. The following events occur and new scheduling decisions are made: At time 1, J2 completes and hence, J3 becomes ready; J3 is placed in the priority queue ahead of J7 and is scheduled on P2 (P2 was freed by J2). At time 3, both J1 and J3 complete; J5 is still not released; J4 and J7 are scheduled. At time 4, J5 is released. Now we have 3 jobs ready. J7 has the lowest priority; consequently it is preempted and J4 and J5 have the processors. At time 5, J4 completes; J7 resumes on processor P1. At time 6, J5 completes; because J7 is not yet completed, both J6 and J8 are not ready for execution; consequently, P2 becomes idle. J7 finally completes at time 8; J6 and J8 can now be scheduled. Schedule (b) shows a non preemptive schedule according to the same priority assignment. It turns out that for this system the postponment of J5 at time 4 benefits the set of jobs as a whole. In general, nonpreemptive scheduling is not better than preemptive scheduling.

CHAPTER 4 By Radu Muresan University of Guelph Page 9 FOREGROUND BACKGROUND SCHEDULER Simplest priority driven preemptive scheduler Real time tasks are run as foreground tasks; The sporadic, aperiodic, and non real time tasks are run as background tasks the background tasks run at the lowest priority. Assume that we have n foreground periodic tasks T1, T2,..., Tn and one background task T B with its execution time e B. In this case the completion time ct B for the background task is given by:

CHAPTER 4 By Radu Muresan University of Guelph Page 10 EXAMPLE 1 Consider a real time system in which tasks are scheduled using foreground background scheduling of one foreground task T f and one background task T B. Compute the completion time for the background task if:

CHAPTER 4 By Radu Muresan University of Guelph Page 11 ASSIGNMENTS PROBLEM 1. In a simple priority driven preemptive scheduler, two periodic tasks T1 and T2 and a background task T3 are scheduled. The periodic task T1 has the highest priority and executes once every 20 ms and requires 10 ms of execution time each time. T2 requires 20 ms of processing every 50 ms. T3, the background task, requires 100 ms to complete. Assuming that all the tasks start at time 0, determine the time at which T3 will complete. PROBLEM 2. Suppose that in PROBLEM 1, an overload of 1 ms on account of every context switch is to be taken into account. Compute the completion time of T3.

CHAPTER 4 By Radu Muresan University of Guelph Page 12 EARLIEST DEADLINE FIRST (EDF) SCHEDULING November 13 09 6:35 PM In EDF scheduling, at every scheduling point the task having the shortest absolute deadline is taken up for scheduling. A task set is schedulable under EDF, if and only if it satisfies the condition that the total processor utilization due to the task set is less than 1. For a set of periodic real time tasks {T1, T2,..., Tn}, EDF schedulability criterion can be expressed as: EDF has been proven to be an optimal uniprocessor scheduling algorithm. If pi > di, then each task needs ei execution time every min(pi, di). Therefore, Eq (2) can be rewritten as: However, if pi < di, it is possible that a set of tasks is EDF schedulable, even when the task set fails to meet Eq. (3). Therefore, Eq. (3) is conservative in this case and is not a necessary condition, but only a sufficient condition for a given task set to be EDF schedulable.

CHAPTER 4 By Radu Muresan University of Guelph Page 13 EXAMPLE OF EDF SCHEDULE Consider the following task set

CHAPTER 4 By Radu Muresan University of Guelph Page 14 MINIMUM LAXITY FIRST (MLF) scheduling is a variant of EDF. In MLF, at every scheduling point, a laxity value is computed for every task in the system, and the task having the minimum laxity is executed first. Laxity of a task measures the amount of time that would remain if the task is taken up for execution next laxity is a measure of the flexibility available for scheduling a task. Unlike EDF, MLF takes into consideration the execution time of a task Minimum Laxity First (MLF) Algorithm Scheduler checks the slack of all the ready jobs each time a new job is released (Slack = d-t-x) and schedules based: The smaller the slack the higher the priority Ex. {T1,T2} = {(2, 0.9), (5, 2.3)} => MLF identical with EDF Ex.{T1,T2,T3} = {(2, 0.8), (5, 1.5), (5.1,1.5)} => Φi=0; Di=pi Decision Execution (Φi,pi,ei,Di) Φ=0 J1,1 J2,1 J3,1 (p1,e1) (p2,e2) (p3,e3) 2 4 5 10 Decision Execution J1,2 J2,1 J3,1 2 4 5 10 ENGG4420: Real-Time Systems Design; Developed by Radu Muresan 96

CHAPTER 4 By Radu Muresan University of Guelph Page 15 EDF EXAMPLE Consider the 3 periodic real time tasks to be scheduled using EDF on a uniprocessor: T1:(20, 10); T:(50, 5); T3:(35, 10). Determine whether the task set is schedulable.

CHAPTER 4 By Radu Muresan University of Guelph Page 16 IS EDF REALLY A DYNAMIC PRIORITY SCHEDULING ALGORITHM If EDF were to be considered a dynamic priorityscheduling algorithm, we should be able to determine the priority value of each task at any point of time and also be able to show how it changes with time. As described, EDF scheduling does not require any priority value for any task to be computed at any time. Tasks are scheduled solely on their proximity to their deadlines However, the longer the task waits in the ready queue, the higher the chance (probability) of being taken up for scheduling => a virtual priority value associated with a task keeps increasing with time until the task is taken up for scheduling

CHAPTER 4 By Radu Muresan University of Guelph Page 17 EDF Algorithm 0 2 4 6 8 10 0 2 4 6 8 10 (b) RM-Schedule An earliest-deadline-first schedule of (2, 0.9) and (5, 2.3) EDF algorithm: dynamic-priority algorithm assigns priorities to individual jobs in the tasks according to their absolute deadlines task-level dynamic-priority (and job-level fixed-priority) algorithm once a job is placed in the ready queue according to its priority its order with respect to other jobs in the queue remains fixed Ex: Priority of T1 is > priority of T2 from time 0 until time 4 T2 starts to have higher priority at time 4 When job J2,2 is released, T2 again has a lower priority ENGG4420: Real-Time Systems Design; Developed by Radu Muresan 95

CHAPTER 4 By Radu Muresan University of Guelph Page 18 IMPLEMENTATION OF EDF 1. 2. 3. NAIVE IMPLEMENTATION OF EDF: a. b. c. d. e. a. b. c. Maintain all ready tasks in a queue Insert new freshly arriving tasks at the end of queue Every node in the queue will contain the Di of tasks At every preemption point the entire queue will be scanned from beginning to determine the task with the shortest deadline Complexity of the scheme: insertion of a task is achieved in O(1) or constant time; task selection (to run next) and its deletion would require O(n) time. EFFICIENT IMPLEMENTATION 1 OF EDF: a. b. c. d. Maintain all ready tasks in a sorted priority queue that can be efficiently implemented by using a heap data structure the sort criteria is in accordance to the tasks proximity to their deadline When a task arrives, a record for it can be inserted into the heap in O(log 2 n) time At every scheduling point, the next task to be run can be found at the top of the heap => O(1) time. EFFICIENT IMPLEMENTATION 2 OF EDF: Assume that the number of distinct deadlines that tasks in an application can have are restricted A separate FIFO queue is maintained for each distinct relative deadline The scheduler inserts a newly arrived task at the end of the corresponding relative deadline queue => tasks in each queue are ordered according to their absolute deadline Complexity: find the task to run is in O(1) time; time to insert a task is O(1)

CHAPTER 4 By Radu Muresan University of Guelph Page 19 SHORTCOMINGS OF EDF 1. 2. 3. TRANSIENT OVERLOAD PROBLEM: denotes the overload of a system for a very short time. Transient overload occurs when some task takes more time to complete due to reasons such as, entering an infinite loop, entering a rarely used branch due to some abnormal input values, etc. a. When EDF is used to schedule a set of periodic real time tasks, a task overshooting its completion time can cause other task(s) to miss their deadlines. b. We can't predict which task will miss its deadline, and it can happen with the most critical task. RESOURCE SHARING PROBLEM: when EDF is used to schedule a set of real time tasks, unacceptably high overheads might have to be incurred to support resource sharing among the tasks without making tasks to miss their respective deadlines (later). EFFICIENT IMPLEMENTATION PROBLEM: the efficient implementation that assumes a restricted number of tasks with distinct deadlines is not always feasible. For a more flexible EDF algorithm, we need to keep the tasks ordered in terms of their deadlines using a priority queue.