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

Similar documents
Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Lecture 3 Theoretical Foundations of RTOS

Priority-Driven Scheduling

3. Scheduling issues. Common approaches /1. Common approaches /2. Common approaches / /13 UniPD / T. Vardanega 23/01/2013. Real-Time Systems 1

4. Fixed-Priority Scheduling

Advanced Operating Systems (M) Dr Colin Perkins School of Computing Science University of Glasgow

Real-Time Software. Basic Scheduling and Response-Time Analysis. René Rydhof Hansen. 21. september 2010

Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

Periodic Task Scheduling

Common Approaches to Real-Time Scheduling

HARD REAL-TIME SCHEDULING: THE DEADLINE-MONOTONIC APPROACH 1. Department of Computer Science, University of York, York, YO1 5DD, England.

Aperiodic Task Scheduling

Scheduling Real-time Tasks: Algorithms and Complexity

Scheduling Aperiodic and Sporadic Jobs in Priority- Driven Systems

Module 6. Embedded System Software. Version 2 EE IIT, Kharagpur 1

Real Time Scheduling Basic Concepts. Radek Pelánek

Real-Time Scheduling 1 / 39

The simple case: Cyclic execution

Commonly Used Approaches to Real-Time Scheduling

Predictable response times in event-driven real-time systems

Real- Time Scheduling

174: Scheduling Systems. Emil Michta University of Zielona Gora, Zielona Gora, Poland 1 TIMING ANALYSIS IN NETWORKED MEASUREMENT CONTROL SYSTEMS

Today. Intro to real-time scheduling Cyclic executives. Scheduling tables Frames Frame size constraints. Non-independent tasks Pros and cons

Aperiodic Task Scheduling

Real-time scheduling algorithms, task visualization

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Exercises : Real-time Scheduling analysis

Multi-core real-time scheduling

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

Resource Reservation & Resource Servers. Problems to solve

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Scheduling of Real- Time processes, strategies and analysis

LAB 5: Scheduling Algorithms for Embedded Systems

Improved Handling of Soft Aperiodic Tasks in Offline Scheduled Real-Time Systems using Total Bandwidth Server

Partition Scheduling in APEX Runtime Environment for Embedded Avionics Software

REAL TIME OPERATING SYSTEMS. Lesson-18:

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Improvement of Scheduling Granularity for Deadline Scheduler

Operating System Aspects. Real-Time Systems. Resource Management Tasks

CHAPTER 4: SOFTWARE PART OF RTOS, THE SCHEDULER

Least Slack Time Rate First: an Efficient Scheduling Algorithm for Pervasive Computing Environment

Global Multiprocessor Real-Time Scheduling as a Constraint Satisfaction Problem

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

A Survey of Fitting Device-Driver Implementations into Real-Time Theoretical Schedulability Analysis

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

How To Compare Real Time Scheduling To A Scheduled Scheduler On Linux On A Computer System With A Visualization System

Operating Systems. III. Scheduling.

Effective Scheduling Algorithm and Scheduler Implementation for use with Time-Triggered Co-operative Architecture

ICS Principles of Operating Systems

Hard Real-Time Reconfiguration Port Scheduling

Using semantic properties for real time scheduling

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

SOFTWARE VERIFICATION RESEARCH CENTRE THE UNIVERSITY OF QUEENSLAND. Queensland 4072 Australia TECHNICAL REPORT. No Real-Time Scheduling Theory

Modular Real-Time Linux

Real-Time Scheduling and Threads: Basics

Classification - Examples

Priority Inversion Problem and Deadlock Situations

On-line scheduling algorithm for real-time multiprocessor systems with ACO

Real-Time Task Scheduling for Energy-Aware Embedded Systems 1

Real-Time Database Systems: Concepts and Design

Long-term monitoring of apparent latency in PREEMPT RT Linux real-time systems

Time Management II. June 5, Copyright 2008, Jason Paul Kazarian. All rights reserved.

Efficient Scheduling of Sporadic, Aperiodic, and Periodic Tasks with Complex Constraints

Methods and Tools For Embedded Distributed System Scheduling and Schedulability Analysis

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Design Pattern for the Adaptive Scheduling of Real-Time Tasks with Multiple Versions in RTSJ

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

Quality of Service su Linux: Passato Presente e Futuro

Performance of Algorithms for Scheduling Real-Time Systems with Overrun and Overload

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

Scheduling Algorithms for Real-Time Systems

A Comparative Study of Scheduling Algorithms for Real Time Task

STORM. Simulation TOol for Real-time Multiprocessor scheduling. Designer Guide V3.3.1 September 2009

Chapter 5 Process Scheduling

Operating Systems Concepts: Chapter 7: Scheduling Strategies

AN APPROPRIATE ENGINEERING APPROACH

Aperiodic Task Scheduling for Real-Time Systems. Brinkley Sprunt

Processor Scheduling. Queues Recall OS maintains various queues

A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation

Transcription:

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

Lecture Outline Scheduling periodic tasks The rate monotonic algorithm Definition Non-optimality Time-demand analysis... 2

Scheduling Periodic Tasks Simplest real-time system: a set of n periodic tasks characterised by Ti = (φi, pi, ei, Di) for i = 1, 2,, n Simplified model: Ti = (pi, ei) when φi = 0 and Di = pi Tasks are independent, with no resource constraints Assume a single processor system There are no aperiodic or sporadic tasks Must schedule system to ensure all deadlines met What type of job scheduler is used? What scheduling algorithm is used? How to prove correctness of the schedule? 3

Job Schedulers Clock driven scheduler Decisions on what job execute made at specific time instants Usually regularly spaced, implemented using a periodic timer interrupt: scheduler awakes after each interrupt, schedules the job to execute for the next period, then sleeps until the next interrupt E.g. the furnace control example, with an interrupt every 100ms Primarily used for static systems, with schedule computed at design time and encoded as a fixed table Behaviour depends on algorithm used to assign jobs to time slots Priority driven scheduler Scheduler chooses what to run at job release or completion time, based on some notion of job priority; will always run a job, if one available Flexible, as scheduling decisions made at runtime, but hard to validate Behaviour depends on algorithm used to assign priorities to jobs 4

Scheduling Algorithms Wide range of scheduling algorithms used: Rate monotonic (RM) Deadline monotonic (DM) Earliest deadline first (EDF) Least slack time (LST) Trade-off optimality, stability, and ease of validation 5

Proving Correctness of a Schedule Modelling Periodic Tasks A set of periodic tasks repeats after hyper-period, H = lcm(pi) for i = 1, 2,, n If the system can be scheduled for one hyper-period, it can be scheduled for! The hyper-period of a set of periodic tasks is the least common multiple of their periods: H = lcm(p i ) for i = 1, 2,, n all, given no aperiodic or sporadic tasks, and no resource constraints Can demonstrate correctness of schedule by exhaustive simulation, or using a mathematical! Time after which proof the of pattern correctness of job release/execution times starts to repeat, limiting analysis needed! Example:! T 1 : p 1 = 3, e 1 = 1! T 2 : p 2 = 5, e 2 = 2 H = lcm(3, 5) = 15 J 1,1 J 1,2 J 1,3 J 1,4 J 1,5 Copyright 2006 University of Glasgow All rights reserved. J 2,1 J 2,2 J 2,2 J 2,3 0 5 10 15 20 25 30 6 Time

The Rate Monotonic Algorithm Assign priorities to jobs in each task based on the period of that task Shorter period higher priority; rate (of job releases) is the inverse of the period, so jobs with higher rate have higher priority Rationale: schedule jobs with most deadlines first, fit others around them All jobs in a task have the same priority fixed priority algorithm For example, consider a system of 3 tasks: T1 = (4, 1) rate = 1/4 T2 = (5, 2) rate = 1/5 T3 = (20, 5) rate = 1/20 Relative priorities: T1 > T2 > T3 7

Rate Monotonic: Example Time Ready to run Running 0 J 2,1 J 3,1 J 1,1 1 J 3,1 J 2,1 2 J 3,1 J 2,1 3 J 3,1 4 J 3,1 J 1,2 5 J 3,1 J 2,2 6 J 3,1 J 2,2 7 J 3,1 8 J 3,1 J 1,3 9 J 3,1 Time Ready to run Running 10 J 3,1 J 2,3 11 J 3,1 J 2,3 12 J 3,1 J 1,4 13 J 3,1 14 J 3,1 15 J 2,4 16 J 2,4 J 1,5 17 J 2,4 18 19 All tasks meet deadlines: proof by exhaustive simulation Low priority tasks (e.g., T 3 ) frequently preempted Released 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 J 3,1 J 1,1 J 2,1 J 3,1 J 1,2 J 2,2 J 3,1 J 1,3 J 3,1 J 2,3 J 1,4 J 3,1 J 2,4 J 1,5 J 2,4 0 4 8 12 16 20 T 1 = (4, 1) T 2 = (5, 2) T 3 = (20, 5) 8

Rate Monotonic is Not Optimal Proof by counter-example: A system of two independent periodic tasks, T1 = (2, 1) and T2 = (5, 2.5), scheduled preemptively on a single processor: H = 10, U = 1.0 there is no slack time Rate monotonic fails to meet deadlines, EDF (discussed later) succeeds J2,1 misses deadline Deadlines J 1,1 J 1,2 J 1,3 J 1,4 J 1,5 J 2,1 J 2,2 RM J 1,1 J 2,1 J 1,2 J 2,1 J 1,3 J 2,1 J 2,2 J 1,4 J 2,2 J 1,5 J 2,2 EDF J 1,1 J 2,1 J 1,2 J 2,1 J 1,3 J 2,2 J 1,4 J 2,2 J 1,5 J 2,2 0 2 4 6 8 10 9

Time Demand Analysis Exhaustive simulation error prone and tedious an alternative is time demand analysis Fixed priority algorithms predictable; do not suffer scheduling anomalies The worst case execution time of the system occurs with the worst case execution time of the jobs, unlike dynamic priority algorithms which can exhibit anomalous behaviour Basis of general proof that system can be scheduled to meet all deadlines Find critical instants when system is most loaded, and has its worst response time Use time demand analysis to check if system can be scheduled at those instants In absence of scheduling anomalies, system will meet all deadlines if it can be scheduled at critical instants 10

Finding Critical Instants Critical instant of a job is the worst-case release time for that job, taking into account all jobs that have higher priority i.e., job is released at the same instant as all jobs with higher priority are released, and must wait for all those jobs to complete before it executes Response time, wi,k, of a job released at a critical instant is the maximum possible response time of that job Definition of a critical instant: if wi,k Di,k for every Ji,k in Ti then The job released at that instant has maximum response time of all jobs in Ti and Wi = wi,k All jobs meet deadlines, but this is when job with the slowest response is started else if Ji,k : wi,k > Di,k then The job released at that instant has response time > D where wi,k is the response time of the job If some jobs don t meet deadlines, this is one of those jobs 11

Finding Critical Instants: Example T 1 = (2.0, 0.6) T 2 = (2.5, 0.2) T 3 = (3.0, 1.2) 0 1 2 3 4 5 6 7 8 9 10 11 12 3 tasks scheduled using the rate-monotonic algorithm Response times of jobs in T 2 are: r 2,1 = 0.8, r 2,2 = 0.2, r 2,3 = 0.2, r 2,4 = 0.2, r 2,5 = 0.8, Therefore critical instants of T 2 are t = 0 and t = 10 12

Time-demand Analysis Simulate system behaviour at the critical instants For each job Ji,c released at a critical instant, if Ji,c and all higher priority tasks complete executing before their relative deadlines the system can be scheduled Compute the total demand for processor time by a job released at a critical instant of a task, and by all the higher-priority tasks, as a function of time from the critical instant; check if this demand can be met before the deadline of the job: Consider one task, Ti, at a time, starting highest priority and working down to lowest priority Focus on a job, Ji, in Ti, where the release time, t0, of that job is a critical instant of Ti At time t0 + t for t 0, the processor time demand wi(t) for Xi 1 t this job and all higher-priority jobs released in [t0, t] is: w i (t) =e i + w i (t) is the time-demand function k=1 p k e k Execution time of job J i Execution time of higher priority jobs started during this interval 13

Using the Time-demand Function Compare time-demand function, wi(t), and available time, t: If wi(t) t at some t Di, the job, Ji, meets its deadline, t0 + Di If wi(t) > t for all 0 < t Di then the task probably cannot complete by its deadline; and the system likely cannot be scheduled using a fixed priority algorithm Note that this is a sufficient condition, but not a necessary condition. Simulation may show that the critical instant never occurs in practice, so the system could be feasible Use this method to check that all tasks are can be scheduled if released at their critical instants; if so conclude the entire system can be scheduled 14

Time-demand Analysis: Example w 3 (t) The time-demand, wi(t), is a staircase function with steps at multiples of higher priority task periods 10 J 3,1 starts with a time demand of 5 units: 2 for itself, 2 for J 2,1, 1 for J 1,1 t w 2 (t) Plot the time-demand versus available time graphically, to get intuition into approach Example: a rate monotonic system T 1 = (3, 1), T 2 = (5, 2), T 3 = (10, 2) U = 0.933 Time-demand functions w 1 (t), w 2 (t) and w 3 (t) are below t at deadlines, so the system can be scheduled simulate the system to check this! Time-demand function, w i (t) 8 6 4 2 0 Deadline for J 2,1 Deadline for J 1,1 0 2 4 6 8 10 J 3,1 deadline Time, t w 1 (t) 15

Time-demand Analysis Works for any fixed-priority scheduling algorithm with periodic tasks where Di < pi for all tasks Only a sufficient test: System can be scheduled if time demand less than time available before critical instants But, might be possible to schedule if time demand exceeds available time further validation (i.e., exhaustive simulation) needed in this case 16

Summary The real-time scheduling problem for periodic tasks The rate monotonic algorithm Simple, fixed-priority, algorithm Non-optimal Proofs of correctness of a schedule using exhaustive simulation and timedemand analysis Next lecture: Alternative proofs of correctness for rate monotonic schedules Other algorithms: deadline monotonic, earliest deadline first, least slack time 17