ENGG4420 CHAPTER 4 LECTURE 3 GENERALIZED TASK SCHEDULER

Similar documents
GENERALIZED TASK SCHEDULER

CHAPTER 4 CONTENT October :10 PM

ELC 4438: Embedded System Design Real-Time Scheduling

DEADLINE MONOTONIC ALGORITHM (DMA)

Clock-Driven Scheduling

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

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

א א א א א א א א

CPU Scheduling. Chapter 9

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

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

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

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

CS510 Operating System Foundations. Jonathan Walpole

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

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

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

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

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

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

CPU scheduling. CPU Scheduling

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

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

CS 143A - Principles of Operating Systems

Operating System 9 UNIPROCESSOR SCHEDULING

Project 2 solution code

CSC 553 Operating Systems

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

Real-Time Systems. Modeling Real-Time Systems

CSE 5343/7343 Fall 2006 PROCESS SCHEDULING

CS 111. Operating Systems Peter Reiher

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

Principles of 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)

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

Motivation. Types of Scheduling

CPU Scheduling: Part I. Operating Systems. Spring CS5212

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

Lecture 11: Scheduling

Chapter 9 Uniprocessor Scheduling

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

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

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

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

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

Advanced Types Of Scheduling

Rate Monotonic Analysis

CPU Scheduling (Chapters 7-11)

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

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

Uniprocessor Scheduling

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

Real-Time Scheduler Design For Embedded System Domain

SE350: Operating Systems. Lecture 6: Scheduling

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

Lecture 11: CPU Scheduling

Real-Time Scheduling Theory and Ada

CSE 451: Operating Systems Spring Module 8 Scheduling

Simulation of Process Scheduling Algorithms

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

Periodic task scheduling

September 30 th, 2015 Prof. John Kubiatowicz

SCHEDULING AND CONTROLLING PRODUCTION ACTIVITIES

Performance Comparison of RTS Scheduling Algorithms

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

Operating Systems. Scheduling

Reference model of real-time systems

Scheduling theory, part 1

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

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

Real-time System Overheads: a Literature Overview

IJCSC VOLUME 5 NUMBER 2 JULY-SEPT 2014 PP ISSN

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

Slack Assessment of the Real Time Scheduling Algorithms

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

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

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

CPU Scheduling. Jo, Heeseung

CS 153 Design of Operating Systems Winter 2016

Scheduling. CSE Computer Systems November 19, 2001

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

A Paper on Modified Round Robin Algorithm

Process Scheduling Course Notes in Operating Systems 1 (OPESYS1) Justin David Pineda

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

The Design of SMART: A Scheduler for Multimedia Applications

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

Review of Round Robin (RR) CPU Scheduling Algorithm on Varying Time Quantum

CPU Scheduling. Jo, Heeseung

Process Scheduling I. COMS W4118 Prof. Kaustubh R. Joshi hdp://

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

Scheduling issues in mixedcriticality

Chapter 3: Planning and Scheduling Lesson Plan

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

Transcription:

CHAPTER 4 By Radu Muresan University of Guelph Page 1 ENGG4420 CHAPTER 4 LECTURE 3 November 14 12 9:44 AM 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 to 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

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); repeat above instruction for all tasks in period 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 2

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 14 12 10:06 AM 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 require 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. This 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 (tasks) 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 Ji > Jk 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 14 12 10:27 AM 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) or Least Slack Time First (LST) scheduling is a variant of EDF. In MLF, at every scheduling point, a laxity or slack 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)} => LST 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 J 1,1 J 2,1 J 3,1 (p1,e1) (p2,e2) (p3,e3) 2 4 5 10 Decision Execution J 1,2 J 2,1 J 3,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 THEOREM When preemption is allowed and jobs do not contend for resources, the LST (MLF) algorithm can produce a feasible schedule of a set J of jobs with arbitrary release times and deadlines on a processor if and only if feasible schedules of J. IN CLASS EXAMPLE Calculation of the slack values LST requires knowledge of the execution times of jobs while EDF doesn't. The execution times of jobs are not normally known until the job completes this is a disadvantage. Typically, the slack of each job is calculated based on the maximum execution time e i+ when the range [e i, e i+ ] of the execution time ei of every job is relatively small. Another requirement is that the execution time of each sporadic and aperiodic job become known upon arrival of the jobs.

CHAPTER 4 By Radu Muresan University of Guelph Page 16 EDF EXAMPLE Consider 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.