CLOCK DRIVEN SCHEDULING

Similar documents
Introduction to Real-time Systems. Advanced Operating Systems (M) Lecture 2

Precedence Graphs Revisited (Again)

Source EE 4770 Lecture Transparency. Formatted 16:43, 30 April 1998 from lsli

Scheduling Algorithm and Analysis

Introduction to Embedded Systems

3 No-Wait Job Shops with Variable Processing Times

4/6/2011. Informally, scheduling is. Informally, scheduling is. More precisely, Periodic and Aperiodic. Periodic Task. Periodic Task (Contd.

Multiprocessor and Real-Time Scheduling. Chapter 10

Simplified design flow for embedded systems

Minimum sum multicoloring on the edges of trees

Event-Driven Scheduling. (closely following Jane Liu s Book)

Introduction to Real-Time Systems and Multitasking. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Reference Model and Scheduling Policies for Real-Time Systems

A Framework for Space and Time Efficient Scheduling of Parallelism

Scan Scheduling Specification and Analysis

Lecture 2. 1 Introduction. 2 The Set Cover Problem. COMPSCI 632: Approximation Algorithms August 30, 2017

Response Time Analysis of Asynchronous Real-Time Systems

11.1 Facility Location

An Approach to Task Attribute Assignment for Uniprocessor Systems

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015

Real-Time Architectures 2004/2005

6 Randomized rounding of semidefinite programs

15-854: Approximations Algorithms Lecturer: Anupam Gupta Topic: Direct Rounding of LP Relaxations Date: 10/31/2005 Scribe: Varun Gupta

Discrete Optimization. Lecture Notes 2

Figure 1: An example of a hypercube 1: Given that the source and destination addresses are n-bit vectors, consider the following simple choice of rout

Multiprocessor and Real- Time Scheduling. Chapter 10

Overview. Sporadic tasks. Recall. Aperiodic tasks. Real-time Systems D0003E 2/26/2009. Loosening D = T. Aperiodic tasks. Response-time analysis

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institution of Technology, IIT Delhi

/ Approximation Algorithms Lecturer: Michael Dinitz Topic: Linear Programming Date: 2/24/15 Scribe: Runze Tang

Advanced Operations Research Techniques IE316. Quiz 1 Review. Dr. Ted Ralphs

15-451/651: Design & Analysis of Algorithms October 11, 2018 Lecture #13: Linear Programming I last changed: October 9, 2018

Mathematical and Algorithmic Foundations Linear Programming and Matchings

Dynamic Programming Algorithms

Clustering: Centroid-Based Partitioning

Algorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48

4 Integer Linear Programming (ILP)

Analyzing Real-Time Systems

Time Triggered and Event Triggered; Off-line Scheduling

Announcements. CSEP 521 Applied Algorithms. Announcements. Polynomial time efficiency. Definitions of efficiency 1/14/2013

Lecture 3: Graphs and flows

CSC 373: Algorithm Design and Analysis Lecture 3

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

CS4514 Real Time Scheduling

Greedy Homework Problems

Compositional Schedulability Analysis of Hierarchical Real-Time Systems

PCP and Hardness of Approximation

6.001 Notes: Section 4.1

Approximation Algorithms

1. Lecture notes on bipartite matching February 4th,

Local-Deadline Assignment for Distributed Real-Time Systems

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Theorem 2.9: nearest addition algorithm

Priority-driven Scheduling of Periodic Tasks (2) Advanced Operating Systems (M) Lecture 5

Unsplittable Flows. Hoon Cho and Alex Wein Final Project

Online Stochastic Matching CMSC 858F: Algorithmic Game Theory Fall 2010

Graph-Based Models for Real-Time Workload: A Survey

Lecture 11: Maximum flow and minimum cut

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

Primal Dual Schema Approach to the Labeling Problem with Applications to TSP

Frequently asked questions from the previous class survey

CSE 548: Analysis of Algorithms. Lecture 13 ( Approximation Algorithms )

Approximation Algorithms

Notes for Lecture 24

Algorithm Design and Analysis

TImath.com. Geometry. Triangle Inequalities

PACKING DIGRAPHS WITH DIRECTED CLOSED TRAILS

MOST attention in the literature of network codes has

(Refer Slide Time: 00:18)

Systems of Inequalities

ARELAY network consists of a pair of source and destination

Flexible Coloring. Xiaozhou Li a, Atri Rudra b, Ram Swaminathan a. Abstract

Fault tolerant scheduling in real time systems

Lecture 12: An Overview of Scheduling Theory

Scheduling Algorithm for Hard Real-Time Communication in Demand Priority Network

Greedy Algorithms CHAPTER 16

An Exact Algorithm for the Statistical Shortest Path Problem

Transforming Distributed Acyclic Systems into Equivalent Uniprocessors Under Preemptive and Non-Preemptive Scheduling

The Encoding Complexity of Network Coding

1. Lecture notes on bipartite matching

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Introduction to Real-Time Systems ECE 397-1

CS 372: Computational Geometry Lecture 10 Linear Programming in Fixed Dimension

Microkernel/OS and Real-Time Scheduling

Lecture 9: Load Balancing & Resource Allocation

CMPSCI611: Approximating SET-COVER Lecture 21

LECTURES 3 and 4: Flows and Matchings

An Improved Priority Ceiling Protocol to Reduce Context Switches in Task Synchronization 1

Priority Queues. 1 Introduction. 2 Naïve Implementations. CSci 335 Software Design and Analysis III Chapter 6 Priority Queues. Prof.

2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006

COE428 Lecture Notes Week 1 (Week of January 9, 2017)

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Generalized Pebbling Number

Homework index. Processing resource description. Goals for lecture. Communication resource description. Graph extensions. Problem definition

Dynamic Programming Algorithms

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Module 6 NP-Complete Problems and Heuristics

4.1 Interval Scheduling

CHAPTER 3 A TIME-DEPENDENT k-shortest PATH ALGORITHM FOR ATIS APPLICATIONS

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

Topic: Local Search: Max-Cut, Facility Location Date: 2/13/2007

Transcription:

CHAPTER 4 By Radu Muresan University of Guelph Page 1 ENGG4420 CHAPTER 4 LECTURE 2 and 3 November 04 09 7:51 PM CLOCK DRIVEN SCHEDULING Clock driven schedulers make their scheduling decisions regarding which task to run next, only at the clock interrupt points Scheduling points are determined by timer interrupts Clock driven schedulers are also called off line schedulers because these schedulers fix the schedule before the system starts to run (predetermines which task will run when). These schedulers incur very little run time overhead SHORTCOMING OF THIS CLASS OF SCHEDULERS is that they cannot satisfactorily handle aperiodic and sporadic tasks The exact time of occurrence of these tasks cannot be predicted. As a result, these schedulers are also called static schedulers. 1) 2) IMORTANT CLOCK DRIVEN SCHEDULERS ARE: Table driven Cyclic schedulers

CHAPTER 4 By Radu Muresan University of Guelph Page 2 TABLE DRIVEN SCHEDULING Table driven schedulers usually precompute which task would run and when and store this schedule in a table at the time the system is designed or configured. The application programmer can be given the freedom to select his own schedule for the set of tasks in the application and store the schedule in a table called schedule table to be used by the scheduler at the run time. An important question for this type of scheduler is what would be the SIZE OF THE SCHEDULE TABLE that would be required for a given set of tasks in system?

CHAPTER 4 By Radu Muresan University of Guelph Page 3 THE SIZE OF THE SCHEDULE TABLE Given a set of n tasks ST = {Ti}, then the entries in the schedule table will replicate themselves after the major cycle of the set ST. The major cycle of the set ST is the Least Common Multiple of the periods of all the tasks in ST: LCM(p1, p2,..., pn), where p1, p2,..., pn are the periods of T1, T2,..., Tn. For any given task set it is sufficient to store the entries only for LCM(p1, p2,..., pn) duration in the schedule table. DEFINITION: a major cycle of a set of tasks is an interval of time on the time line such that in each major cycle, the different tasks recur identically. The above reasoning assumed that all tasks are in phase meaning that Φi = 0.

CHAPTER 4 By Radu Muresan University of Guelph Page 4 THEOREM: The major cycle of a set of tasks ST = {T1, T2,..., Tn) is LCM{p1, p2,..., pn} even when the tasks have arbitrary phasing. PROOF. Let's assume that the occurrences of a task Ti in a major cycle are as shown below. In figure above there are k 1 occurrences of the task Ti in the major cycle M. The first occurrence of Ti starts at φ The major cycle M ends x time units after the last occurrence of Ti (i.e., Ti(k 1)). Of course this scenario must be the same in all major cycles. Inspecting the figure above we can conclude that for a task to repeat identically in each major cycle we need to have: M = (k 1)*pi + φ + x; (1) Now, for the task Ti to have identical occurrence times in each major cycle, φ + x must equal to pi. Substituting this in Eq. (1) we get: M = (k 1)*pi + pi = k*pi; (2) As a result of (2) M contains an integral multiple of pi and this argument holds for each task in the set. THEREFORE, M = LCM({p1, p2,..., pn}).

CHAPTER 4 By Radu Muresan University of Guelph Page 5 CYCLIC SCHEDULERS Many small embedded applications are based on cyclic schedulers that are simple, efficient, and easy to program. For example a temperature controller within a computer controlled air conditioner. A cyclic scheduler repeats a precomputed schedule that is stored for one major cycle. Each task in the task set to be scheduled repeats identically in every major cycle. The major cycle is divided into one or more minor cycles and each minor cycle is called a frame. THE SCHEDULING POINTS of a cyclic scheduler occur at frame boundaries. As a result, a task can start executing only at the beginning of a frame. The frame boundaries are defined through interrupts generated by a periodic timer. Each tasks is assigned to run in one or more frames The assignment of tasks to frames is stored in a schedule table.

CHAPTER 4 By Radu Muresan University of Guelph Page 6 SELECTING THE SIZE OF THE FRAME The size of the frame to be used by the scheduler is an important design parameter and needs to be chosen carefully. A frame size should satisfy the following 3 constraints: 1) Minimum context switching 2) Minimization of table size 3) Satisfaction of task deadline MINIMUM CONTEXT SWITCHING This constraint aims to minimize the number of context switching during task execution. As a result, a task should complete running within its assigned frame. Otherwise the task might have to be suspended and restarted in a later frame. To avoid unnecessary context switches, the selected frame size should be larger than the execution time of each task. FORMALLY the constraint is: max ({ei}) F (1) Where, ei is the execution time of the task Ti, and F is the frame size. Note that this constraint imposes a lower bound on frame size, i.e., the frame size F must not be smaller than max ({ei}).

CHAPTER 4 By Radu Muresan University of Guelph Page 7 MINIMIZATION OF TABLE SIZE The constraint 2 requires that the number of entries in the schedule table should be minimum in order to minimize the storage requirement of the schedule table. Minimization of the number of entries to be stored in the schedule table can be achieved when the minor cycle F squarely divides the major cycle M. No fractional minor cycles in M so we don't need to store the table for more than one M

CHAPTER 4 By Radu Muresan University of Guelph Page 8 SATISFACTION OF TASK DEADLINE Constraint 3 imposes that between the arrival of a task and its deadline, there must exist at least one full frame this constraint arises from the fact that a task can only be taken up for scheduling at the start of a frame. If between the arrival and completion of a task not even one frame exists, a situation as shown in figure above might arise in this case the task arrives a little after the k th frame and can't be taken for scheduling until frame (k+1). However, if the execution time e of T is greater than x then T misses its deadline. We therefore, need a full frame to exist between the arrival of a task and its deadline.

CHAPTER 4 By Radu Muresan University of Guelph Page 9 THE FORMULATION OF CONSTRAINT 3 Assume that a single frame is sufficient to complete T The task can complete before its deadline if: 2F Δt d; or 2F Δt + d The worst case scenario for a task to meet its deadline occurs for its instance that has the minimum separation from the start of frame (in this case the task would have to wait the longest before its execution can start) The determination of the minimum separation value (i.e., min(δt) for a task among all instances of the task would help in determining a feasible frame size. Next theorem shows that min(δt) = GCD(F, pi); => Here GCD is the greatest common multiple.

CHAPTER 4 By Radu Muresan University of Guelph Page 10 THEOREM MINIMUM SEPARATION Theorem. The minimum separation of the task arrival from the corresponding frame start time (min(δt)) considering all instances of a task Ti is equal to GCD(F, pi). (GCD means greatest common divisor) PROOF. Let g = GCD(F, pi) => g must divide squarely F and pi; Let Ti be a task with 0 phasing; Assume that the Theorem is violated for certain integers m and n, such that Ti(n) occurs in the m th frame and the difference between the start time of m th frame and the arrival of n th instance of the task Ti is less than g; That is, We proved that the minimum separation can't be smaller than GCD(F, pi).

CHAPTER 4 By Radu Muresan University of Guelph Page 11 SELECTING A FRAME SIZE For a given task set it is possible that more than one frame size satisfies all the 3 constraints. In such cases, it is better to choose the shortest frame size. This is because the schedulability of a task set increases as more number of frames become available in a major cycle. A suitable frame size for a task set does not assure a feasible schedule for the task set. It may so happen that there are not enough number of frames available in a major cycle to be assigned to all the task instances. Next we show 2 examples. In Example 1 we can find a suitable frame size that satisfies all 3 constraints. However, it is possible that a suitable frame size may not exist for many problems (Example 2): In such cases, to find a feasible frame size we might have to split the task (or a few tasks) that is (are) causing the violation of the constraints into smaller sub tasks that can be scheduled in different frames. It is difficult to come up with a set of guidelines to identify the exact task that is to be split, and the parts into which it needs to be split. This can therefore be done by trial and error.

CHAPTER 4 By Radu Muresan University of Guelph Page 12 EXAMPLE 1 A cyclic scheduler is to be used to run the following set of periodic tasks on a uniprocessor: T1:(4, 1); T2:(5, 1); T3:(20, 1); T4:(20, 1.5). 1. 2. 3. Select an appropriate frame size. SOLUTION. For the given task set, an appropriate frame size is the one that satisfies all the 3 required constraints. Below we determine a suitable frame size F that satisfies all 3 constraints. Constraint 1. Let F be an appropriate frame size, then max {1, 1, 1, 1.5} F. From this constraint F 1.5; Constraint 2. The major cycle M for the given task set is given by M = LCM(4, 5, 20, 20) = 20. M should be an integral multiple of the frame size F, i.e., M mod F = 0. This consideration implies that F {2, 4, 5, 10, 20}. Note: Frame size of 1 has been ruled out since it would violate the constraint 1. Constraint 3. To satisfy this constraint, we need to check whether a selected frame size F satisfies the inequality: 2F GCD(F, pi) di; for each pi. Next page shows the calculations for Constraint 3.

CHAPTER 4 By Radu Muresan University of Guelph Page 13

CHAPTER 4 By Radu Muresan University of Guelph Page 14 EXAMPLE 2 Consider the following set of periodic real time tasks to be scheduled by a cyclic scheduler: T1:(4, 1); T2:(5, 2); T3:(20, 5). Determine the frame size for the task set. SOLUTION. Using Constraint 1 => F 5; Using Constraint 2 => M = LCM(4, 5, 20) = 20 As a result the set of values for F is {5, 10, 20}. Checking for a frame size that satisfies Constraint 3, we can find that no value of F is suitable. To overcome this problem, we need to split the task that is making the task set unschedulable; It is easy to observe that task T3 has the largest execution time, and consequently due to Constraint 1 makes the feasible frame size quite large. We try to split T3 into 3 sub tasks. After splitting T3 into 3 tasks, we have: T3,1 = (20, 1, 20); T3,2 = (20, 2, 20); T3,3 = (20, 2, 20). Now the new possible values of F are 2 and 4. We can check that after splitting the tasks, F = 2 and F = 4 are feasible frame sizes we pick the smallest one.

CHAPTER 4 By Radu Muresan University of Guelph Page 15 ALGORITHM FOR CONSTRUCTING STATIC SCHEDULES Scheduling Independent Preemptable Tasks; The Iterative Network-Flow (INF) Algorithm The general problem of choosing minor frame length for a given set of periodic tasks, segmenting the tasks if necessary, and scheduling the tasks that meet all their deadlines is NP-hard Step 1: Find all possible frame sizes of the system that meet the frame size constrains 2 and 3 but not necessarily constraint 1; Step 2: Apply INF algorithm starting with the largest possible frame; The INF algorithm iteratively tries to find a feasible cyclic schedule of the system for a possible frame size at a time, starting with the largest value Example that meets constraints (2) and (3) but not 1 T1=(4,1); T2=(5,2,7) and T3=(20,5) Frame sizes: 2 and 4 ENGG4420: Real-Time Systems Design; Developed by Radu Muresan 82 The INF algorithm iteratively tries to find a feasible cyclic schedule of the system for a possible frame size at a time, starting from the largest possible frame size in order of decreasing frame size. A feasible schedule thus found tells us how to decompose some tasks into subtasks if their decomposition is necessary. If the algorithm fails to find a feasible schedule after all the possible frame sizes have been tried, the given tasks do not have a feasible cyclic schedule that satisfies the frame size constraints even when tasks can be decomposed into subtasks.

CHAPTER 4 By Radu Muresan University of Guelph Page 16 Network-Flow Graph The algorithm used in each iteration is based on the network-flow formulation of the preemptive scheduling problem In this formulation we ignore the tasks to which the jobs belong we name the jobs in a major cycle of F frames as J1, J2,..., JN the constraints are represented by a graph The graph contains the following vertices, edges Job vertex Ji, i=1,..., N Frame vertex j, j=1,..., F Vertices source and sink Edges (Ji,j) if job Ji can be scheduled in frame j edge capacity = f Edges from source to every job vertex Ji edge capacity = ei Edges from every frame vertex to the sink edge capacity = f ENGG4420: Real-Time Systems Design; Developed by Radu Muresan 83 J1, J2,..., JN is an enumeration of all tasks instances that need to be scheduled in the major cycle M that contains F frames. Here a job can be understood as an instance of a task.

CHAPTER 4 By Radu Muresan University of Guelph Page 17 Network Flow Graph Algorithm Jobs/Major cycle J1 J2 JN Frames/Major cycle 1 2 3 F A flow of an edge is a positive number that satisfies the following constraints: < the edge capacity (flow into vertexes) = (flow out) Flow of a networkflow graph = (all flows into the sink) Problem: Find the maximum flow of network-flow graph (e i ), e i Jobs J i (f), h x (f), e k source (e k ), e k (f), 0 ENGG4420: Real-Time Systems Design; Developed by Radu Muresan J k (f) e i -h Frames z y... F (f), h (f), e i +e k -h (f), 0 (f), 0 84 sink A flow of an edge is a nonnegative number that satisfies the following two constraints: (1) It is no greater than the capacity of the edge and (2) with the exception of the source and sink, the sum of the flows of all the edges into every vertex is equal to the sum of the flows of all the edges out of the vertex. This slide shows part of a network flow graph. The label (capacity), flow of each edge gives its capacity and flow. This graph indicates that job Ji can be scheduled in frames x and y and the job Jk can be scheduled in frames y and z. A flow of a network flow graph, or simply a flow, is the sum of the flows of all the edges from the source and it should equal to the sum of the flows of all the edges into the sink. There are many algorithms for finding the maximum flows of network flow graphs. The time complexity of the straightforward ones is O((N+F)^3).

CHAPTER 4 By Radu Muresan University of Guelph Page 18 Maximum Flow and Feasible Preemptive Schedule The flow of an edge (Ji,j) gives the amount of time in frame j allocated to job Ji The maximum flow (all job times per major cycle) The set of flows of edges from job vertices to frame vertices that gives the maximum flow represents a feasible preemptive schedule of the jobs in the frame source (1),1 (1), 1 (1),1 (1),1 (1),1 (2), 2 (2), 2 (2), 2 (2), 2 (2), 2 J 1+1 J 1+2 J 1+3 J 1+4 J 1+5 J 2+1 J 2+2 J 2+3 J 2+4 (4),2 (4),1 (4),1 (4),1 (4),0 (4),1 (4),2 (4),1 (4),2 (4),2 4 (4),2 (4),3 (4),0 2 1 3 (4),4 (4),4 (4),3 (4),3 (4),4 sink J 3+1 ENGG4420: Real-Time Systems Design; Developed by Radu Muresan (4),1 5 85 Clearly, the maximum flow of a network flow graph defined above is at most equal to the sum of the execution times of all the jobs to be scheduled in a major cycle. The set of flows of edges from job vertices to frame vertices that gives this maximum flow represents a feasible preemptible schedule of the jobs in the frames. Specifically, the flow of an edge (Ji, j) from a job vertex Ji to a frame vertex j gives the amount of time in frame j allocated to job Ji. This figure considers the previous example with tasks T1, T2, and T3. The possible frame sizes that satisfy Constraints 2 and 3 are f= 4 and 2. The network flow graph used in the first iteration when f=4 is shown in this figure. We want every job to be scheduled in a frame which begins no sooner than its release time and ends no later than its deadline. This is reason for the edges from the job vertices to the frame vertices. The maximum flow of this graph is 18, which is the total execution time of all the jobs in a hyperperiod. Hence, the flows of edges from the job vertices to the frame vertices represent a schedule of the tasks. It is possible that the maximum flow of a network flow graph is less than the sum of the execution times of all N jobs. This fact indicates that the given tasks have no feasible schedule with the frame size used to generate the graph.

WORK PAGE EXAMPLE CHAPTER 4 By Radu Muresan University of Guelph Page 19