Real-Time and Embedded Systems (M) Lecture 4

Similar documents
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

CHAPTER 4 CONTENT October :10 PM

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

Lecture 6: Scheduling. Michael O Boyle Embedded Software

DEADLINE MONOTONIC ALGORITHM (DMA)

Reference model of real-time systems

The BEST Desktop Soft Real-Time Scheduler

Real-Time Systems. Modeling Real-Time Systems

Real-time System Overheads: a Literature Overview

A Reference Model of Real-Time Systems

Preference-Oriented Fixed-Priority Scheduling for Real-Time Systems

Real-Time Scheduling Theory and Ada

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

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

Motivation. Types of Scheduling

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

Principles of Operating Systems

Advanced Types Of Scheduling

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

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

Preemptive Scheduling of Multi-Criticality Systems with Varying Degrees of Execution Time Assurance

Scheduling II. To do. q Proportional-share scheduling q Multilevel-feedback queue q Multiprocessor scheduling q Next Time: Memory management

Slack Assessment of the Real Time Scheduling Algorithms

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

Lecture 11: CPU Scheduling

Technical Report CMU/SEI-89-TR-14 ESD-TR-89-; 022. Carnegie-Mellon University. Software Engineering Institute. Real-Time Scheduling Theory

Gang Scheduling Performance on a Cluster of Non-Dedicated Workstations

Operations and Supply Chain Management Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

Hadoop Fair Scheduler Design Document

On-line Multi-threaded Scheduling

Job Scheduling Challenges of Different Size Organizations

Swift mode changes in memory constrained real-time systems

Asymptotic Analysis of Real-Time Queues

SINGLE MACHINE SEQUENCING. ISE480 Sequencing and Scheduling Fall semestre

Operating System 9 UNIPROCESSOR SCHEDULING

SCHEDULING IN MANUFACTURING SYSTEMS

Motivating Examples of the Power of Analytical Modeling

Job Scheduling in Cluster Computing: A Student Project

Classification of Real-Time Systems

Introduction to software testing and quality process

Pallab Banerjee, Probal Banerjee, Shweta Sonali Dhal

Energy Aware Resource Allocation for Data Center

CPU Scheduling. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

SELF OPTIMIZING KERNEL WITH HYBRID SCHEDULING ALGORITHM

Fixed-Priority Preemptive Multiprocessor Scheduling: To Partition or not to Partition

OPERATING SYSTEMS. Systems and Models. CS 3502 Spring Chapter 03

CPU Scheduling. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Journal of Global Research in Computer Science

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

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

Operating Systems Process Scheduling Prof. Dr. Armin Lehmann

M3 Group System. General. In This Section

ure Outline edulability tests for fixed-priority systems ctical factors nues from material in lecturee 5, with the same assumption

Recall: FCFS Scheduling (Cont.) Example continued: Suppose that processes arrive in order: P 2, P 3, P 1 Now, the Gantt chart for the schedule is:

DEADLINE SCHEDULING FOR REAL-TIME SYSTEMS. EDF and Related Algorithms

A COMPARATIVE ANALYSIS OF SCHEDULING ALGORITHMS

Energy-Efficient Scheduling of Interactive Services on Heterogeneous Multicore Processors

Optimized Virtual Resource Deployment using CloudSim

Resource Allocation Strategies in a 2-level Hierarchical Grid System

What is Waveless Processing and How Can It Optimize My Operation?

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

An Omniscient Scheduling Oracle for Systems with Harmonic Periods

Justifying Simulation. Why use simulation? Accurate Depiction of Reality. Insightful system evaluations

CMS readiness for multi-core workload scheduling

Operations and Supply Chain Simulation with AnyLogic

Triage: Balancing Energy and Quality of Service in a Microserver

SEQUENCING & SCHEDULING

9. Verification, Validation, Testing

SimSo: A Simulation Tool to Evaluate Real-Time Multiprocessor Scheduling Algorithms

A Paper on Modified Round Robin Algorithm

10/1/2013 BOINC. Volunteer Computing - Scheduling in BOINC 5 BOINC. Challenges of Volunteer Computing. BOINC Challenge: Resource availability

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

A Decomposition Approach for the Inventory Routing Problem

Comparative Analysis of Scheduling Algorithms of Cloudsim in Cloud Computing

Harold s Hot Dog Stand Part I: Deterministic Process Flows

Managing CPU Utilization with WLM Resource Groups

G54SIM (Spring 2016)

An Agent-Based Scheduling Framework for Flexible Manufacturing Systems

Vehicle Routing with Cross Docks, Split Deliveries, and Multiple Use of Vehicles. Arun Kumar Ranganathan Jagannathan

CHAPTER 2 LITERATURE SURVEY

Single Machine Scheduling with Interfering Job Sets

6.1.9 IFM Initial Conditions

Workload Decomposition for Power Efficient Storage Systems

This article appeared in a journal published by Elsevier. The attached copy is furnished to the author for internal non-commercial research and

Towards the design of certifiable mixed-criticality systems

California Independent System Operator Corporation Fifth Replacement Electronic Tariff

CS162 Operating Systems and Systems Programming Lecture 10. Tips for Handling Group Projects Thread Scheduling

Pricing with Bandwidth Guarantees for Clients with multi-isp Connections

Reoptimization Gaps versus Model Errors in Online-Dispatching of Service Units for ADAC

Differential Analysis: Relevant Costs the Key to Decision Making

ISO : Rustam Rakhimov (DMS Lab)

Job-Length Estimation and Performance in Backlling Schedulers. University of Maryland, College Park.

TAAG: An Efficient Task Allocation Algorithm for Grid Environment

An Evaluation of Alternative Permissive Periods on Non-Coordinated Phase Performance in Coordinated Traffic Signal Systems

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

CELLULAR BASED DISPATCH POLICIES FOR REAL-TIME VEHICLE ROUTING. February 22, Randolph Hall Boontariga Kaseemson

Simulation of an Interdependent Metro-Bus Transit System to Analyze Bus Schedules from Passenger Perspective

Kanban kick- start (v2)

The use of the Animate Transfer toolbar and various transportation-related modules will be illustrated in three examples in the sequel.

Transcription:

Clock-Driven Scheduling Real-Time and Embedded Systems (M) Lecture 4

Lecture Outline Assumptions and notation for clock-driven scheduling Handling periodic jobs Static, clock-driven schedules and the cyclic executive Handling aperiodic jobs Slack stealing Handling sporadic jobs Advantages and disadvantages of clock driven scheduling Material corresponds to chapter 5 of Liu s book

Assumptions Clock-driven scheduling applicable to deterministic systems A restricted periodic task model: The parameters of all periodic tasks are known a priori For each mode of operation, system has a fixed number, n, periodic tasks For task T i each job J i,k is ready for execution at its release time r i,k and is released p i units of time after the previous job in T i such that r i,k = r i,k-1 + p i Variations in the inter-release times of jobs in a periodic task are negligible Aperiodic jobs may exist Assume that the system maintains a single queue for aperiodic jobs Whenever the processor is available for aperiodic jobs, the job at the head of this queue is executed There are no sporadic jobs Recall: sporadic jobs have hard deadlines, aperiodic jobs do not

Notation The 4-tuple T i = (φ i, p i, e i, D i ) refers to a periodic task T i with phase φ i, period p i, execution time e i, and relative deadline D i Default phase of T i is φ i = 0, default relative deadline is the period D i = p i Omit elements of the tuple that have default values Examples: = (1, 10, 3, 6) φ 1 = 1 p 1 = 10 e 1 = 3 D 1 = 6 J 1,1 released at 1, deadline 7 J 1,2 released at 11, deadline 17 = (10, 3, 6) φ 2 = 0 p 2 = 10 e 2 = 3 D 2 = 6 J 1,1 released at 0, deadline 6 J 1,2 released at 10, deadline 16 T 3 = (10, 3) φ 3 = 0 p 3 = 10 e 3 = 3 D 3 = 10 J 1,1 released at 0, deadline 10 J 1,2 released at 10, deadline 20

Static, Clock-driven Cyclic Scheduler Since the parameters of all jobs with hard deadlines are known can construct a static cyclic schedule in advance Processor time allocated to a job equals its maximum execution time Scheduler dispatches jobs according to the static schedule, repeating each hyperperiod Static schedule guarantees that each job completes by its deadline No job overruns all deadlines are met Schedule calculated off-line can use complex algorithms Run-time of the scheduling algorithm irrelevant Can search for a schedule that optimizes some characteristic of the system e.g. a schedule where the idle periods are nearly periodic; accommodating aperiodic jobs The book gives an example, but scheduling algorithm unimportant as long as resulting schedule meets deadline

Example Cyclic Schedule Consider a system with 4 independent periodic tasks: Period = ( 4, 1.0) Execution time = ( 5, 1.8) [Phase and deadline take default values] T 3 = (20, 1.0) T 4 = (20, 2.0) Hyper-period H = 20 (least common multiple of 4, 5, 20, 20) Can construct an arbitrary static schedule to meet all deadlines: Feasible intervals Execution times T 3 T 4 0 4 8 12 16 20 Slack time, can be used to execute aperiodic jobs.

Implementing a Cyclic Scheduler Store pre-computed schedule as a table k t k T(t k ) The system creates all the tasks that are to be executed: 0 1 2 0.0 1.0 2.0 T 3 Allocates sufficient memory for the code and data of every task 3 4 3.8 4.0 I Brings the code executed by the task into memory Scheduler sets the hardware timer to interrupt at the first decision time, t k=0 On receipt of an interrupt at t k : 5 6 7 8 9 10 5.0 6.0 8.0 9.8 10.8 12.0 I T 4 I Scheduler sets the timer interrupt to expire at t k+1 If previous task overrunning, handle failure If T(t k ) = I and aperiodic job waiting, start aperiodic job Otherwise, start next job in task T(t k ) executing 11 12 13 14 15 16 13.8 14.8 17.0 17.0 18.0 19.8 I I I

Implementing a Cyclic Scheduler Input: stored schedule (t k, T(t k )) for k = 0, 1, n 1. Task SCHEDULER: set the next decision point i = 0 and table entry k = 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 + t k ; 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.

Structured Cyclic Schedules Arbitrary table-driven cyclic schedules flexible, but inefficient Relies on accurate timer interrupts, based on execution times of tasks High scheduling overhead Easier to implement if structure imposed: Make scheduling decisions at periodic intervals (frames) of length f Execute a fixed list of jobs with each frame, disallowing pre-emption except at frame boundaries Require phase of each periodic task to be a non-negative integer multiple of the frame size The first job of every task is released at the beginning of a frame φ = k f where k is a non-negative integer Gives two benefits: Scheduler can easily check for overruns and missed deadlines at the end of each frame Can use a periodic clock interrupt, rather than programmable timer

Frame Size Constraints How to choose frame length? To avoid preemption, want jobs to start and complete execution within a single frame: f max(e 1, e 2,, e n ) (Eq.1) To minimize the number of entries in the cyclic schedule, the hyper-period should be an integer multiple of the frame size ( f divides evenly into the period of at least one task): i : mod(p i, f ) = 0 (Eq.2) To allow scheduler to check that jobs complete by their deadline, should be at least one frame boundary between release time of a job and its deadline: 2*f gcd(p i, f ) D i for i = 1, 2,, n (Eq.3) (see section 5.3.2 of book for derivation of Eq.3) All 3 constraints should be satisfied

Frame Size Constraints Example Review the system of independent periodic tasks from our earlier example: = (4, 1.0) = (5, 1.8) T 3 = (20, 1.0) T 4 = (20, 2.0) Constraints: Eq.1 f max(1, 1.8, 1, 2) 2 Eq.2 f { 2, 4, 5, 10, 20 } Eq.3 2f - gcd( 4, f ) 4 ( ) 2f - gcd( 5, f ) 5 ( ) 2f - gcd(20, f ) 20 (T 3, T 4 ) Hyper-period H = lcm(4, 5, 20, 20) = 20 Only value that satisfies all constraints is f = 2 Feasible intervals Execution times T 3 T 4 0 2 4 6 8 10 12 14 16 18 20

Job Slices Sometimes, a system cannot meet all three frame size constraints simultaneously Can often solve by partitioning a job with large execution time into slices (sub-jobs) with shorter execution times/deadlines Gives the effect of preempting the large job, so allow other jobs to run Sometimes need to partition jobs into more slices than required by the frame size constraints, to yield a feasible schedule Example: Consider a system with = (4, 1), = (5, 2, 7), T 3 = (20, 5) Cannot satisfy constraints: Eq.1 f 5 but Eq.3 f 4 Solve by splitting T 3 into T 3,1 = (20, 1), T 3,2 = (20, 3) and T 3,3 = (20,1) Other possible splits exist; pick based on application domain knowledge Result can be scheduled with f = 4

Building a Structured Cyclic Schedule To construct a cyclic schedule, we need to make three kinds of design decisions: Choose a frame size based on constraints Partition jobs into slices Place slices in frames These decisions cannot be taken independently: Ideally want as few slices as possible, but may be forced to use more to get a feasible schedule

Implementation: A Cyclic Executive Modify previous table-driven cyclic scheduler to be frame based, schedule all types of jobs in a multi-threaded system Table that drives the scheduler has F entries, where Each corresponding entry L(k) lists the names of the job slices that are scheduled to execute in frame k; called a scheduling block Each job slice implemented by a procedure, to be called in turn Cyclic executive executed by the clock interrupt that signals the start of a frame: Determines the appropriate scheduling block for this frame Executes the jobs in the scheduling block in order F = H f Starts job at head of the aperiodic job queue running for remainder of frame Less overhead than pure table driven cyclic scheduler, since only interrupted on frame boundaries, rather than on each job

Scheduling Aperiodic Jobs Thus far, aperiodic jobs are scheduled in the background after all jobs with hard deadlines scheduled in each frame have completed Delays execution of aperiodic jobs in preference to periodic jobs However, note that there is often no advantage to completing a hard realtime job early, and since an aperiodic job is released due to an event, the sooner such a job completes, the more responsive the system Hence, minimizing response times for aperiodic jobs is typically a design goal of real-time schedulers

Scheduling Aperiodic Jobs: Slack Stealing Periodic jobs scheduled in frames that end before their deadline; there may be some slack time in the frame after the periodic job completes Since we know the execution time of periodic jobs, can move the slack time to the start of the frame, running the periodic jobs just in time to meet their deadline Execute aperiodic jobs in the slack time, ahead of periodic jobs The cyclic executive keeps track of the slack left in each frame as the aperiodic jobs execute, preempts them to start the periodic jobs when there is no more slack As long as there is slack remaining in a frame, the cyclic executive returns to examine the aperiodic job queue after each slice completes Reduces response time for aperiodic jobs, but requires accurate timers

Scheduling Sporadic Jobs We assumed there were no sporadic jobs what if this is relaxed? Sporadic jobs have hard deadlines, release and execution times that are not known a priori Hence, a clock-driven scheduler cannot guarantee a priori that sporadic jobs complete in time However, scheduler can determine if a sporadic job is schedulable when it arrives Perform an acceptance test to check whether the newly released sporadic job can be feasibly scheduled with all the jobs in the system at that time If there is sufficient slack time in the frames before the new job s deadline, the new sporadic job is accepted; otherwise, it is rejected Can be determined that a new sporadic job cannot be handled as soon as that job is released; earliest possible rejection If more than one sporadic job arrives at once, they should be queued for acceptance in EDF order

Practical Considerations Handling overruns: Jobs are scheduled based on maximum execution time, but failures might cause overrun A robust system will handle this by either: 1) killing the job and starting an error recovery task; or 2) preempting the job and scheduling the remainder as an aperiodic job Depends on usefulness of late results, dependencies between jobs, etc. Mode changes: A cyclic scheduler needs to know all parameters of real-time jobs a priori Switching between modes of operation implies reconfiguring the scheduler and bringing in the code/data for the new jobs This can take a long time: schedule the reconfiguration job as an aperiodic or sporadic task to ensure other deadlines met during mode change Multiple processors: Can be handled, but off-line scheduling table generation more complex

Clock-driven Scheduling: Advantages 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, can be captured in the schedule When 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 Relatively easy to validate, test and certify

Clock-driven Scheduling: Disadvantages Inflexible Pre-compilation of knowledge into scheduling tables means that if anything changes materially, have to redo the table generation Best suited for systems which are rarely modified once built Other disadvantages: Release times of all jobs must be fixed All possible combinations of periodic tasks that can execute at the same time must be known a priori, so that the combined schedule can be precomputed The treatment of aperiodic jobs is very primitive Unlikely to yield acceptable response times if a significant amount of soft realtime computation exists

Summary We have discussed: Static, clock-driven schedules and the cyclic executive Handling aperiodic jobs Slack stealing Handling sporadic jobs Advantages and disadvantages of clock driven scheduling Clock-driven scheduling applicable to static systems, small number of aperiodic jobs The next lecture begins our study of priority scheduling for more dynamic environments