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



Similar documents
4. Fixed-Priority Scheduling

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

Predictable response times in event-driven real-time systems

Scheduling of Real- Time processes, strategies and analysis

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

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

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

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

Periodic Task Scheduling

Lecture 3 Theoretical Foundations of RTOS

The simple case: Cyclic execution

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

Sustainability in Real-time Scheduling

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

Real- Time Scheduling

Priority-Driven Scheduling

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

CPU Scheduling. CPU Scheduling

ICS Principles of Operating Systems

Aperiodic Task Scheduling

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

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

Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d

Scheduling Real-time Tasks: Algorithms and Complexity

Scheduling Sporadic Tasks with Shared Resources in Hard-Real-Time Systems

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

Aperiodic Task Scheduling

N. Audsley. A. Burns Department of Computer Science, University of York, UK. ABSTRACT

Classification - Examples

Real Time Scheduling Basic Concepts. Radek Pelánek

Ada Real-Time Services and Virtualization

Real-Time Scheduling 1 / 39

CPU Scheduling. Core Definitions

Operating Systems. III. Scheduling.

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

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

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

An Efficient Non-Preemptive Real-Time Scheduling

AN APPROPRIATE ENGINEERING APPROACH

Attaining EDF Task Scheduling with O(1) Time Complexity

Processor Scheduling. Queues Recall OS maintains various queues

Exercises : Real-time Scheduling analysis

Partition Scheduling in APEX Runtime Environment for Embedded Avionics Software

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

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Partitioned EDF Scheduling for Multiprocessors using a C=D Scheme

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

Cache-aware compositional analysis of real-time multicore virtualization platforms

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

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

TIME PREDICTABLE CPU AND DMA SHARED MEMORY ACCESS

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

Common Approaches to Real-Time Scheduling

Implementing and Using Execution Time Clocks in Ada Hard Real-Time Applications

Jorix kernel: real-time scheduling

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

Lec. 7: Real-Time Scheduling

Hierarchical Real-Time Scheduling and Synchronization

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Objectives. Chapter 5: Process Scheduling. Chapter 5: Process Scheduling. 5.1 Basic Concepts. To introduce CPU scheduling

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

Multi-core real-time scheduling

Overview of Presentation. (Greek to English dictionary) Different systems have different goals. What should CPU scheduling optimize?

Predictable response times in eventdriven real-time systems

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

Hardware Task Scheduling and Placement in Operating Systems for Dynamically Reconfigurable SoC

Fitting Linux Device Drivers into an Analyzable Scheduling Framework

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

W4118 Operating Systems. Instructor: Junfeng Yang

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

Dispatching Domains for Multiprocessor Platforms and their Representation in Ada

CHAPTER 4: SOFTWARE PART OF RTOS, THE SCHEDULER

Resource Synchronization in Hierarchically Scheduled Real-Time Systems using Preemptive Critical Sections

Partitioned real-time scheduling on heterogeneous shared-memory multiprocessors

Chapter 5 Process Scheduling

!! #!! %! #! & ((() +, %,. /000 1 (( / 2 (( 3 45 (

OPERATING SYSTEMS SCHEDULING

What is best for embedded development? Do most embedded projects still need an RTOS?

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

Task Attribute-Based Scheduling - Extending Ada s Support for Scheduling

Quantum Support for Multiprocessor Pfair Scheduling in Linux

Operating System: Scheduling

Commonly Used Approaches to Real-Time Scheduling

Scheduling. Monday, November 22, 2004

Real-Time Scheduling and Threads: Basics

A Comparative Study of Scheduling Algorithms for Real Time Task

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

LAB 5: Scheduling Algorithms for Embedded Systems

Operating Systems, 6 th ed. Test Bank Chapter 7

Complexity of scheduling real-time tasks subjected to cache-related preemption delays

Operating Systems Concepts: Chapter 7: Scheduling Strategies

REAL TIME OPERATING SYSTEMS. Lesson-18:

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

Real-time scheduling algorithms, task visualization

From Control Loops to Software

Performance Comparison of RTOS

Cache-Aware Compositional Analysis of Real-Time Multicore Virtualization Platforms

Transcription:

Real-Time Software Basic Scheduling and Response-Time Analysis René Rydhof Hansen 21. september 2010 TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 1 / 28

Last Time Time in a real-time programming language Access to a clock Delay Timeouts Temporal scopes Deadline, minimum delay, maximum delay, maximum execution time, maximum elapse time TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 2 / 28

Today s Goals To understand the simple process model To be able to schedule simple systems using the cyclic executive approach To understand process-based scheduling To be able to perform utilization-based schedulability tests To be able to perform response time analysis for FPS To understand the concept of WCET and the role it plays To understand the role of scheduling and schedulability in ensuring RTSs meet their deadlines TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 3 / 28

Scheduling Definition A mechanism to restrict non-determinism in a concurrent system Features generally provided An algorithm for ordering the use of system resources CPU (most often) Bus-bandwidth Harddisks... Predictable worst case behaviour under the given scheduling algorithm TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 4 / 28

Standard Notation B Worst-case blocking time for the process C Worst-case computation time (WCET) D Deadline of the process I The interference time of the process J Release kitter of the process N Number of processes in the system P Priority assigned to the process R Worst-case response time of the process T Minimum time between releases (process period) U Utilisation of each process (equal to C/T) a-z Process name TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 5 / 28

The Cyclic Executive Approach Common way of implementing a hard RTS Concurrent design, but sequential code (collection of procedures) Procedures are mapped onto a sequence of minor cycles Minor cycles constitute the complete schedule: the major cycle Minor cycle determines the minimum period Major cycle determines the maximum cycle time Major Advantage Fully deterministic TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 6 / 28

Cyclic Executive Example Process Period Computation Time a 25 10 b 25 8 c 50 5 d 50 4 e 100 2 loop w a i t f o r m i n o r c y c l e ; p r o c a ; p r o c b ; p r o c c ; w a i t f o r m i n o r c y c l e ; p r o c a ; p r o c b ; p r o c d ; p r o c e ; w a i t f o r m i n o r c y c l e ; p r o c a ; p r o c b ; p r o c c ; w a i t f o r m i n o r c y c l e ; p r o c a ; p r o c b ; p r o c d ; end loop ; TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 7 / 28

Cyclic Executive: Properties No actual processes exist at run-time (only procedures) Minor cycles are sequences of procedure calls Procedures share a common address space Useful for inter- process communication Does not need to be protected: concurrent access not possible All process periods must be a multiple of minor cycle time TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 8 / 28

Cyclic Executive: Problems Difficult to incorporate processes with long periods Major cycle time determines maximum period Can (sometimes) be (partially) solved with secondary scheduling Sporadic processes are difficult to incorporate Difficult to construct and maintain (NP-hard) Time-consuming processes must be split Fixed number of fixed sized procedures May cut across useful and well-established boundaries Potentially very bad for software engineering (error prone) More flexible scheduling methods are difficult to support Determinism is not required but predictability is TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 9 / 28

Process-Based Scheduling Approaches Fixed-Priority Scheduling (FPS) Earliest Deadline First (EDF) Value-Based Scheduling (VBS) The Simple Process Model The application has a fixed set of processes All processes are periodic with known periods The processes are independent of each other All processes have deadline equal to their period All processes have a fixed worst-case execution time All context-switching costs etc. are ignored No internal suspension points (e.g., delay or blocking I/O) All processes execute on a single CPU TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 10 / 28

Fixed-Priority Scheduling (FPS) Definition (FPS) Each process has a fixed, static, priority assigned before run-time Priority determines execution order Most widely used approach Conceptually simple Well-understood Well-supported Main focus of the course Priority Importance In RTSs the priority of a process is derived from its temporal requirements, not its importance to the correct functioning of the system or its integrity TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 11 / 28

Earliest Deadline First (EDF) Definition (EDF) Execution order is determined by the absolute deadlines The next process to run is the one with the shortest (nearest) deadline EDF with relative deadlines Often only relative deadlines are specified Absolute deadlines can be computed at run-time (dynamic scheduling) TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 12 / 28

Value-Based Scheduling (VBS) Definition (VBS) Assign a value to each process Use on-line value-based scheduling algorithm Basically: schedule process with highest value Adaptive schemes necessary for systems that can be overloaded Static priorities and/or deadlines not sufficient Easier to factor in widely differing factors Easier (conceptually) to handle unforeseen events TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 13 / 28

Preemption and Non-Preemption With priority-based scheduling, a high-priority process may be released during the execution of a lower priority one In a preemptive scheme, there will be an immediate switch to the higher-priority process With non-preemption, the lower-priority process will be allowed to complete before the high-priority executes Preemptive schemes enable higher-priority processes to be more reactive, and hence they are preferred Alternative strategies allow a lower priority process to continue to execute for a bounded time These schemes are known as deferred preemption or cooperative dispatching Schemes such as EDF and VBS can also take on a preemptive or non-preemptive form TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 14 / 28

Rate Monotonic Priority Assignment (FPS) Each process is assigned a (unique) priority based on its period: the shorter the period, the higher the priority: T i < T j = P i > P j This assignment is optimal in the sense that if any process set can be scheduled (using pre-emptive priority-based scheduling) with a fixed-priority assignment scheme, then the given process set can also be scheduled with a rate monotonic assignment scheme Note: priority 1 (one) is the lowest (least) priority Example (Priority Assignment) Process Period(T) Priority (P) a 25 b 60 c 42 d 105 e 75 TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 15 / 28

Rate Monotonic Priority Assignment (FPS) Each process is assigned a (unique) priority based on its period: the shorter the period, the higher the priority: T i < T j = P i > P j This assignment is optimal in the sense that if any process set can be scheduled (using pre-emptive priority-based scheduling) with a fixed-priority assignment scheme, then the given process set can also be scheduled with a rate monotonic assignment scheme Note: priority 1 (one) is the lowest (least) priority Example (Priority Assignment) Process Period(T) Priority (P) a 25 5 b 60 3 c 42 4 d 105 1 e 75 2 TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 15 / 28

Utilisation-Based Analysis for FPS Assume rate monotonic priority assignment Sufficient schedulability test for D = T task sets: U U 0.69 as N Utilisation bounds N Utilisation Bound 1 100.0% 2 82.8% 3 78.0% 4 75.7% 5 74.3% 10 71.8% N i=1 C i T i N (2 1 N 1) TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 16 / 28

Process Set A: Utilisation Based Schedulability Test Example (Utilisation Test for Process Set A) Process Period Computation Time Priority Utilisation a 50 12 1 0.24 b 40 10 2 0.25 c 30 10 3 0.33 The combined utilisation is 0.82 Above threshold for three processes (0.78): process set failed utilisation test TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 17 / 28

Process Set B: Utilisation Based Schedulability Test Example (Utilisation Test for Process Set B) Process Period Computation Time Priority Utilisation a 80 32 1 0.400 b 40 5 2 0.125 c 16 4 3 0.250 The combined utilisation is 0.775 Below threshold for three processes (0.78): utilisation test succeeded (will meet all deadlines) TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 18 / 28

Process Set C Example (Utilisation Test for Process Set C) Process Period Computation Time Priority Utilisation a 80 40 1 0.50 b 40 10 2 0.25 c 20 5 3 0.25 The combined utilisation is 1.0 Above threshold for three processes (0.78)... but the process set will meet all its deadlines Utilisation Based Schedulability Test Sufficient but not necessary TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 19 / 28

Utilisation-based Tests for FPS: Problems Not exact Not general (only T = D) But is O(N) The test is sufficient but not necessary TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 20 / 28

Utilisation-based Test for EDF A much simpler test N i=1 C i T i 1 Superior to FPS; it can support high utilisation FPS is easier to implement as priorities are static EDF requires more complex run-time system with higher overhead Easier to incorporate other factors into a priority than into a deadline During overload situations FPS is more predictable; low priority processes miss their deadlines first EDF is unpredictable; domino effect may occur: large number of processes miss deadlines Utilisation-based tests: binary answer TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 21 / 28

Response-Time Analysis Calculating the Slowest Response Calculate i s worst-case response time: R i = C i + I. Where I is the interference from higher priority tasks Check (trivially) if deadline is met R i D i Calculating I During R i task j (with P j > P i ) is released Total interference by task j is given by: Ri C j T j Ri T j number of times. The ceiling function, x : the smallest integer greater than x, e.g., 0.25 = 1 TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 22 / 28

Response Time Equation Worst Case Response Time R i = C i + j hp(i) Ri T j C j where hp(i) is the set of tasks with priority higher than task i Solve by forming a recurrence relationship: = C i + R n i R n+1 i j hp(i) T j C j The set of values Ri 0, R1 i, R2 i,..., Rn i,... is monotonically non-decreasing. When Ri n = R n+1 i the solution to the equation has been found, Ri 0, must not be greater than R i (use e.g., 0 or C i ) TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 23 / 28

Process Set C: Revisited Example (Response Time Analysis for Process Set C) Process Period Computation Time Priority Response Time a 80 40 1 80 b 40 10 2 15 c 20 5 3 5 The combined utilisation is 1.0 This is above the (utilisation) threshold for three processes (0.78) The response time analysis shows that the process set will meet all its deadlines Response Time Analysis Necessary and sufficient TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 24 / 28

Response Time Analysis Is sufficient and necessary If the process set passes the test, all processes meet all their deadlines If the process set fails the test a process will miss its deadline at run-time Modulo wrong estimates, e.g., pessimistic computation time estimate TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 25 / 28

Worst-Case Execution Time (WCET) Definition The maximum amount of execution time a task needs to complete (under all possible circumstances). Obtained by either measurement or analysis Measurement: hard to guarantee that the worst case has been observed (measured) Never gives too pessimistic results Hard to automate Analysis requires effective processor model (including caches, pipelines, memory wait states and other exotic hardware) Bad hardware model may lead to unsound WCET analysis or imprecise (too pessimistic) estimates Can be (partly) automated TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 26 / 28

Exercises 1 [BW] 11.1 2 [BW] 11.2 3 [BW] 11.3 4 [BW] 11.7 5 [BW] 11.9 6 [BW] 11.10 TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 27 / 28

Summary Summary: Basic Scheduling: Cyclic executive, FPS, EDF, VBS Utilisation analysis for FPS, EDF Response time analysis for simple process model TSW (2010e) (Lecture 05) Real-Time Software 21. september 2010 28 / 28