Precedence Graphs Revisited (Again)

Similar documents
Scheduling Algorithm and Analysis

2. Introduction to Software for Embedded Systems

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

Subject Name: OPERATING SYSTEMS. Subject Code: 10EC65. Prepared By: Kala H S and Remya R. Department: ECE. Date:

Concurrent activities in daily life. Real world exposed programs. Scheduling of programs. Tasks in engine system. Engine system

Tasks. Task Implementation and management

Introduction to Embedded Systems

Simplified design flow for embedded systems

Learning Outcomes. Scheduling. Is scheduling important? What is Scheduling? Application Behaviour. Is scheduling important?

CLOCK DRIVEN SCHEDULING

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

Global Scheduling in Multiprocessor Real-Time Systems

Introduction to Real-Time Systems ECE 397-1

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Computer Science 4500 Operating Systems

Microkernel/OS and Real-Time Scheduling

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

Time Triggered and Event Triggered; Off-line Scheduling

requests or displaying activities, hence they usually have soft deadlines, or no deadlines at all. Aperiodic tasks with hard deadlines are called spor

Overview of Scheduling a Mix of Periodic and Aperiodic Tasks

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

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

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

Multimedia Systems 2011/2012

A Capacity Sharing and Stealing Strategy for Open Real-time Systems

TDDD07 Real-time Systems Lecture 10: Wrapping up & Real-time operating systems

Lecture 3. Introduction to Real-Time kernels. Real-Time Systems

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Reference Model and Scheduling Policies for Real-Time Systems

Implementing Task Schedulers (1) Real-Time and Embedded Systems (M) Lecture 10

Lecture 12: An Overview of Scheduling Theory

Real-time operating systems and scheduling

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable)

Dynamic Voltage Scaling of Periodic and Aperiodic Tasks in Priority-Driven Systems Λ

A Predictable RTOS. Mantis Cheng Department of Computer Science University of Victoria

ECE519 Advanced Operating Systems

Embedded Software Programming

Multiprocessor and Real-Time Scheduling. Chapter 10

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

Real-Time Architectures 2004/2005

Interactive Scheduling

Two Level Scheduling. Interactive Scheduling. Our Earlier Example. Round Robin Scheduling. Round Robin Schedule. Round Robin Schedule

Exam Review TexPoint fonts used in EMF.

Time Handling in Programming Language

Copyright Notice. COMP9242 Advanced Operating Systems S2/2014 Week 9: Real-Time Systems. Real-Time System: Definition

Hardware/Software Partitioning and Scheduling of Embedded Systems

Systemy RT i embedded Wykład 11 Systemy RTOS

Real-time Support in Operating Systems

Process Management And Synchronization

Department of Computer Science Institute for System Architecture, Operating Systems Group REAL-TIME MICHAEL ROITZSCH OVERVIEW

6.1 Motivation. Fixed Priorities. 6.2 Context Switch. Real-time is about predictability, i.e. guarantees. Real-Time Systems

238P: Operating Systems. Lecture 14: Process scheduling

Subject Name:Operating system. Subject Code:10EC35. Prepared By:Remya Ramesan and Kala H.S. Department:ECE. Date:

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Embedded Systems. 6. Real-Time Operating Systems

Scheduling Bits & Pieces

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

Analyzing Real-Time Systems

Please do not handin a.doc file, a.zip file, a.tar file, or anything else

Handout. The ARM Instruction Set. Real Time Systems. Real Time Operating Systems. Real Time System Organization. Classification of Real Time Systems

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

Response Time Analysis of Asynchronous Real-Time Systems

Scheduling Periodic and Aperiodic. John P. Lehoczky and Sandra R. Thuel. and both hard and soft deadline aperiodic tasks using xed-priority methods.

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

IN4343 Real-Time Systems

8: Scheduling. Scheduling. Mark Handley

Xinu on the Transputer

Multiprocessor Systems. COMP s1

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

Scheduling II. Today. Next Time. ! Proportional-share scheduling! Multilevel-feedback queue! Multiprocessor scheduling. !

Multiprocessor and Real- Time Scheduling. Chapter 10

A New Real-time Kernel development on an embedded platform

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CSCI 8530 Advanced Operating Systems. Part 10 Clock and Timer Management

Real-Time Operating Systems

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

Operating Systems. Process scheduling. Thomas Ropars.

Aperiodic Task Scheduling

Investigation of System Timing Concerns in Embedded Systems: Tool-based Analysis of AADL Models

Enriching Enea OSE for Better Predictability Support

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

Outline of the talk. The egg and the hen Or, Which comes first: the problem or the solution? Challenges (2/6) Challenges (1/6) Recall of basics

Real Time Kernels and Operating Systems Introduction

Operating Systems Unit 3

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts

OPERATING SYSTEM CONCEPTS UNDERSTAND!!! IMPLEMENT!!! ANALYZE!!!

Design Patterns for Real-Time Computer Music Systems

Abstract. Testing Parameters. Introduction. Hardware Platform. Native System

Process Description and Control. Chapter 3

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

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

Computer Systems Assignment 4: Scheduling and I/O

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

Scheduling, part 2. Don Porter CSE 506

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

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

CS 167 Final Exam Solutions

Operating Systems Unit 6. Memory Management

Transcription:

Precedence Graphs Revisited (Again) [i,i+6) [i+6,i+12) T 2 [i,i+6) [i+6,i+12) T 3 [i,i+2) [i+2,i+4) [i+4,i+6) [i+6,i+8) T 4 [i,i+1) [i+1,i+2) [i+2,i+3) [i+3,i+4) [i+4,i+5) [i+5,i+6) [i+6,i+7) T 5 [i,i+1) [i+1,i+2) [i+2,i+3) [i+3,i+4) [i+4,i+5) [i+5,i+6) [i+6,i+7) T 6 [i,i+1) [i+1,i+2) [i+2,i+3) [i+3,i+4) [i+4,i+5) [i+5,i+6) [i+6,i+7) mod(i,6) 1 2 3 4 5 0 1 22 January 2004 Lecture 4 1 Clock-driven Scheduling This approach is applicable only when the system is mostly deterministic, except for a few aperiodic and sporadic jobs This lecture will assume a restricted periodic task model 1. There are n periodic tasks in the system; as long as the system remains in a particular operation mode, n is fixed 2. The parameters of all period tasks are known a priori; in particular, variations in the inter-release times of jobs in a periodic tasks are negligibly small i.e. each job in T i is released p i units of time after the previous job in T i 3. Each job J i,k is ready for execution at its release time r i,k 22 January 2004 Lecture 4 2

Clock-driven Scheduling Refer to a periodic task T i with phase φ i, period p i, execution time e i, and relative deadline D i by the 4-tuple (φ i, p i, e i, D i ) Default phase of a task is 0, default relative deadline is its period; omit elements of the tuple that have default values Examples: Tuple φ p e D (1, 10, 3, 6) 1 10 3 6 (10,3,6) 0 10 3 6 (10,3) 0 10 3 10 22 January 2004 Lecture 4 3 Clock-driven Scheduling Assume there are aperiodic jobs released at unexpected time instants For now, assume no sporadic jobs (recall that sporadic jobs have hard deadlines, aperiodic jobs do NOT have hard deadlines) Assume that the system maintains a single queue for aperiodic jobs; addition of such jobs to the queue does not require attention of the scheduler; whenever the processor is available for aperiodic jobs, the job at the head of this queue is executed 22 January 2004 Lecture 4 4

Static, Timer-driven Scheduler Since the parameters of jobs with hard deadlines are known before the system begins to execute, construct a static schedule of the jobs off-line; periodic static schedule == cyclic schedule The amount of processor time allocated to every job is equal to its maximum execution time The static schedule guarantees that each job completes by its deadline The scheduler dispatches jobs according to the static schedule; as long as no job ever overruns, all deadlines are met Since the schedule is calculated off-line, we can employ complex, sophisticated algorithms; in particular, we can choose a feasible schedule from all possible feasible schedules that optimizes some characteristic of the system (e.g. the idle periods for the processor are nearly periodic to accommodate aperiodic jobs) 22 January 2004 Lecture 4 5 Static, Timer-driven Scheduler Example - consider a system with 4 independent periodic tasks: = (4, 1), T 2 = (5, 1.8), T 3 = (20, 1), and T 4 = (20, 2) Hyperperiod H is 20 (least common multiple of 4, 5, 20, 20) T1 starts execution at 0, 4, 9.8, 13.8, 16 T2 starts execution at 2, 8, 12, 18 T3 starts execution at 1 T4 starts execution at 6 Idle intervals: (3.8,4), (5,6), (10.8,12), (14.8,16), (17,18), (19.8,20) T 3 T 2 T 4 T 2 T 2 T 2 0 4 8 12 16 20 22 January 2004 Lecture 4 6

Static, Timer-driven Scheduler Can execute aperiodic jobs during the idle intervals May be advantageous to scatter the unused intervals somewhat periodically in the schedule If no aperiodic jobs ready to execute during such intervals, can execute background nonrealtime jobs 22 January 2004 Lecture 4 7 Static, Timer-driven Scheduler Implementing such a scheduler Store the pre-computed schedule as a table Each entry (t k, T(t k )), where t k is a decision time (a time instant when a scheduling decision is to be made) and T(t k ) is either the name of the task to start at that time or I (for idle) During initialization, the system creates all the tasks that are to be executed (allocates sufficient memory for the code and data of every task and brings the code executed by the task into memory) After initialization is complete, the scheduler sets the hardware timer to interrupt at the first decision time Upon receipt of an interrupt at t k, the scheduler sets the timer to expire at t k+1 and prepares the task T(t k ) for execution; it then suspends itself, letting the task have the processor to execute 22 January 2004 Lecture 4 8

Static, Timer-driven Scheduler Input: stored schedule (t k, T(t k )) for k = 0, 1, N 1. Task SCHEDULER: set the next decision point I and table entry k to 0; set the timer to expire at t k ; do forever: accept timer interrupt; if an aperiodic job is executing, preempt the job; current task T = T(t k ); increment i by 1; compute the next table entry k = I mod (N); set the timer to expire at [I / N] * H + tk; if the current task T is I, let the job at the head of the aperiodic queue execute; else, let the task T execute; sleep; end do. End SCHEDULER. 22 January 2004 Lecture 4 9 General structure of cyclic schedules General consensus is that it is better to use cyclic schedules that exhibit some structure, as opposed to using totally ad hoc schedules e.g. make scheduling decisions at periodic intervals, rather than at arbitrary times Such periodic scheduling intervals partition the timeline into frames; there is no pre-emption within frames The phase of each periodic task is a non-negative integer multiple of the frame size i.e. the first job of every task is released at the beginning of a frame 22 January 2004 Lecture 4 10

Frame size constraints Want the frames to be sufficiently long so that every job and start and complete its execution within a frame [eq 1] f max(e 1, e 2,, e n ) To minimize the length of the cyclic schedule, the frame size should divide the hyperperiod of the system; this is true if f divides the period p i of at least one task T i [eq 2] i such that mod(p i, f) = 0 To make it possible for the scheduler to determine that every job completes by its deadline, the frame size should be sufficiently small such that between the release time and deadline of every job, there is at least one frame [eq 3] 2*f gcd(p i, f) D i for i = 1, 2,, n 22 January 2004 Lecture 4 11 Frame size constraints Example - reconsider the system with 4 independent periodic tasks: = (4, 1), T 2 = (5, 1.8), T 3 = (20, 1), and T 4 = (20, 2) Hyperperiod H is 20 (least common multiple of 4, 5, 20, 20) Eq 1 f 2 Eq 2 f { 2, 4, 5, 10, 20 } Eq 3 f = 2 Therefore, f = 2 22 January 2004 Lecture 4 12

Job Slices Sometimes, the task parameters for a system cannot meet all three frame size constraints simultaneously Forced to partition a large-execution-time job in a task into slices/subjobs with smaller execution times To construct a cyclic schedule, we need to make three kinds of design decisions: Choose a frame size Partition jobs into slices Place slices in frames These decisions cannot be taken independently Sometimes we need to partition jobs into more slices than required by the frame size constraints in order to yield a feasible schedule 22 January 2004 Lecture 4 13 Cyclic Executives A table-driven cyclic scheduler for all types of jobs in a multithreaded system Table that drives the scheduler has F entries, where F = H / f; each corresponding entry L(k) lists the names of the job slices that are scheduled to execute in frame k; called a scheduling block Cyclic executive takes over the processor and executes at the clock interrupt that signals the start of a frame It determines the appropriate scheduling block for this frame It executes the jobs in the scheduling block It wakes up jobs in the aperiodic job queue to permit them to use the remaining time in the frame Major assumptions: Existence of a timer Each timer interrupt is handled by the executive in a bounded time 22 January 2004 Lecture 4 14

Scheduling aperiodic jobs Thus far, aperiodic jobs are scheduled in the background after all the job slices with hard deadlines scheduled in each frame have completed Delaying the execution, and hence the completion, of aperiodic jobs in preference to periodic tasks is not necessarily a good one There is no advantage to completing a hard RT job early Since an aperiodic job is released due to an event, the sooner such a job completes, the more responsive the system Minimizing the response times of aperiodic jobs is typically a design goal of real-time schedulers 22 January 2004 Lecture 4 15 Slack Stealing Execute aperiodic jobs ahead of periodic jobs whenever possible in essence, place the idle periods at the beginning of each frame, rather than at the end Every periodic job slice must be scheduled in a frame that ends no later than its deadline When an aperiodic job executes ahead of slices of periodic tasks, it consumes the slack in the frame The cyclic executive must keep a running tally of the slack left in each frame As long as there is slack remaining in a frame, the cyclic executive returns to examine the aperiodic job queue after each slice completes Implementing such an executive: Initial slack in each frame precomputed and stored in table Use an interval timer to keep track of the available slack in the frame At beginning of frame, interval timer set to available slack Timer counts down whenever an aperiodic job executes in the frame When timer expires, executive is interrupted, and preempts the executing aperiodic job 22 January 2004 Lecture 4 16

Scheduling sporadic jobs Sporadic jobs have hard deadlines Since their minimum release times and maximum execution times are not known a priori, impossible to guarantee that all sporadic jobs complete in time Have scheduler perform an acceptance test when each sporadic job is released Check whether the newly released sporadic job can be feasibly scheduled with all the jobs in the system at that time Jobs in the system defined as periodic jobs and sporadic jobs that have been accepted but not yet completed If there is sufficient slack in the frames before the new job s deadline, the new job is accepted; otherwise, it is rejected If more than one sporadic job is queued for acceptance test, EDF can be used for ordering this queue 22 January 2004 Lecture 4 17 Pros of Clock-driven Scheduling Conceptual simplicity Ability to consider complex dependencies, communication delays, and resource contention among jobs when constructing the static schedule, guaranteeing absence of deadlocks and unpredictable delays Entire schedule is captured in a static table Different operating modes can be represented by different tables No concurrency control or synchronization required If completion time jitter requirements exist, these can be captured in the static schedule[s] 22 January 2004 Lecture 4 18

Pros of Clock-driven Scheduling When the workload is mostly periodic and the schedule is cyclic, timing constraints can be checked and enforced at each frame boundary Choice of frame size can minimize context switching and communication overheads Such systems are relatively easy to validate, test and certify 22 January 2004 Lecture 4 19 Cons of Clock-driven Scheduling Such systems are inflexible precompilation of knowledge into the scheduling tables means that if anything changes materially, have to redo the table generation as a result, best suited for systems which are rarely modified once built Other disadvantages: 1. Release times of all jobs must be fixed 2. All combinations of periodic tasks that might execute at the same time must be known a priori so that the combined schedule can be precomputed 3. The treatment of aperiodic jobs is very primitive; if there is a significant amount of soft-real-time computation in the system, it is unlikely that this structure will yield acceptable response times 22 January 2004 Lecture 4 20