Real-Time Scheduling 1 / 39



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

CPU Scheduling Outline

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

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition

ICS Principles of Operating Systems

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

Chapter 5 Process Scheduling

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

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

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

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

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

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

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

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

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

Operating Systems. III. Scheduling.

Operating Systems Concepts: Chapter 7: Scheduling Strategies

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

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Predictable response times in event-driven real-time systems

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

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

CPU Scheduling. Core Definitions

W4118 Operating Systems. Instructor: Junfeng Yang

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

Linux Scheduler. Linux Scheduler

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

Processor Scheduling. Queues Recall OS maintains various queues

CS Fall 2008 Homework 2 Solution Due September 23, 11:59PM

OPERATING SYSTEMS SCHEDULING

Lecture 3 Theoretical Foundations of RTOS

CPU Scheduling. CPU Scheduling

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

Job Scheduling Model

Operating System: Scheduling

Operating Systems, 6 th ed. Test Bank Chapter 7

Linux Process Scheduling Policy

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

4. Fixed-Priority Scheduling

Linux scheduler history. We will be talking about the O(1) scheduler

Improvement of Scheduling Granularity for Deadline Scheduler

W4118 Operating Systems. Instructor: Junfeng Yang

ò Scheduling overview, key trade-offs, etc. ò O(1) scheduler older Linux scheduler ò Today: Completely Fair Scheduler (CFS) new hotness

CPU Scheduling 101. The CPU scheduler makes a sequence of moves that determines the interleaving of threads.

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

The simple case: Cyclic execution

Aperiodic Task Scheduling

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

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

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

Final Report. Cluster Scheduling. Submitted by: Priti Lohani

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

Priority-Driven Scheduling

3 - Introduction to Operating Systems

Windows Server Performance Monitoring

Operating System Tutorial

An Implementation Of Multiprocessor Linux

Main Points. Scheduling policy: what to do next, when there are multiple threads ready to run. Definitions. Uniprocessor policies

UNIVERSITY OF WISCONSIN-MADISON Computer Sciences Department A. Arpaci-Dusseau

Scheduling Algorithms

White Paper Perceived Performance Tuning a system for what really matters

Modular Real-Time Linux

Scheduling Aperiodic and Sporadic Jobs in Priority- Driven Systems

CHAPTER 15: Operating Systems: An Overview

Scheduling. Monday, November 22, 2004

Completely Fair Scheduler and its tuning 1

Konzepte von Betriebssystem-Komponenten. Linux Scheduler. Valderine Kom Kenmegne Proseminar KVBK Linux Scheduler Valderine Kom

Aperiodic Task Scheduling

CHAPTER 4: SOFTWARE PART OF RTOS, THE SCHEDULER

STEPPING TOWARDS A NOISELESS LINUX ENVIRONMENT

REAL TIME OPERATING SYSTEMS. Lesson-10:

Embedded Systems. 6. Real-Time Operating Systems

Multi-core Programming System Overview

Chapter 1: Introduction. What is an Operating System?

EECS 750: Advanced Operating Systems. 01/28 /2015 Heechul Yun

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Chapter 2: OS Overview

Types Of Operating Systems

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

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

Real- Time Scheduling

Chapter 5 Linux Load Balancing Mechanisms

Periodic Task Scheduling

Scheduling in Distributed Systems

SYSTEM ecos Embedded Configurable Operating System

Threads Scheduling on Linux Operating Systems

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

A Group based Time Quantum Round Robin Algorithm using Min-Max Spread Measure

Scheduling policy. ULK3e 7.1. Operating Systems: Scheduling in Linux p. 1

Understanding Linux on z/vm Steal Time

Effective Computing with SMP Linux

Operating Systems Lecture #6: Process Management

Jorix kernel: real-time scheduling

A Survey of Parallel Processing in Linux

Why Relative Share Does Not Work

Running a Workflow on a PowerCenter Grid

Performance Comparison of RTOS

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Commonly Used Approaches to Real-Time Scheduling

Transcription:

Real-Time Scheduling 1 / 39 Multiple Real-Time Processes A runs every 30 msec; each time it needs 10 msec of CPU time B runs 25 times/sec for 15 msec C runs 20 times/sec for 5 msec For our equation, A uses 10/30 of the CPU, B uses 15/40, and C uses 5/50; that s about 81% 2 / 39 1

Diagram A1 A2 A3 A B1 B2 B3 C1 C2 0 10 20 30 40 50 60 70 80 90 A1 must finish before A2 starts, B1 before B2,... 3 / 39 2

Other Issues Some real-time systems permit preemption; some do not Desirability depends on system type (text s discussion is for multimedia system, which are usually preemptible May have aperiodic processes in the mix Static or dynamic scheduling 4 / 39 Rate Monotonic Scheduling A static scheduling algorithm by Lieu and Layland (1973) Conditions: 1. Each periodic process completes within its slot 2. No interprocess dependencies 3. Each process needs the same amount of CPU each time 4. Non-periodic processes have no deadlines 5. Preemption happens instantly with no overhead Yes, this is an oversimplified model... 5 / 39 3

Algorithm Assign a process priority equal to its frequency: A = 33, B = 25, C = 20 Always run the highest-priority runnable process Thus, A can preempt B or C; B can preempt C Proved optimal among class of static algorithms 6 / 39 4

RMS A1 A2 A3 A4 B1 B2 B3 C1 C2 C3 RMS A1 B1 C1 A2 B2 C2 A3 B3 A4 B3C3 0 10 20 30 40 50 60 70 80 90 100 110 Note that B3 is preempted to let A4 run 7 / 39 5

Earliest Deadline First More general model Supports aperiodic events, non-identical CPU bursts Dynamic priority assignment When a process starts, it announces its deadline Priorities are assigned in order of deadline Initially, A goes first, because it has to finish by T = 30; B s deadline is T = 40 and C s is T = 50 8 / 39 6

EDF A1 A2 A3 A4 B1 B2 B3 C1 C2 C3 EDF A1 B1 C1 A2 B2 C2 A3 B3 A4 C3 0 10 20 30 40 50 60 70 80 90 100 110 1 At T = 80, it gives B priority 9 / 39 7

RMS Doesn t Always Work Suppose that A needs 15 msec each time Our formula says we re ok: (15/30 + 15/40 + 5/50) = 97.5% But it fails A1 runs from T = 0 to T = 15; B1 runs from T = 15 to T = 30 At that point, A2 is ready, and has a higher priority than C1; B2 follows it There s no time for C1 before C2 has to start 10 / 39 8

RMS Failure A1 A2 A3 A4 B1 B2 B3 C1 C2 C3 RMS A1 B1 A2 B2? 0 10 20 30 40 50 60 70 80 90 100 110 C1 can t run before C2 has to start 11 / 39 9

Why Did it Fail? RMS is only guaranteed to work if m i=1 C i P i m(2 1/m 1) As m, utilization approaches ln 2 = 0.693 For m = 3, it can fail (though won t always) at 78% Maximum allowed utilization goes down as m increases EDF will succeed for this example The CPU idle period 2.5% will occur every 200 msec 12 / 39 10

EDF Succeeds A1 A2 A3 A4 B1 B2 B3 C1 C2 C3 RMS A1 B1 C1 A2 B2 A3 C2 B3 A4 C 0 10 20 30 40 50 60 70 80 90 100 110 Note that C1 runs before A2 13 / 39 11

Gantt Charts The diagrams I ve been using are called Gantt Charts Useful tool for modeling process scheduling Especially useful with an automated tool 14 / 39 Other Issues 15 / 39 Scheduling Threads With user-level threads, there is no interaction with the scheduler A kernel-level thread implementation relies on the system s scheduler It s often beneficial to schedule several threads from the same process consecutively avoid changes to the memory map Similar logic says keep threads from the same process on a single CPU, if feasible Application-level thread scheduler can handle priorities more easily, though kernel-level priorities aren t hard to set 16 / 39 12

Scheduling and Multiprocessor Systems What processes run on which processor? Does it matter? What are the implications? 17 / 39 Asymmetric Multiprocessing All kernel functions are handled by the master CPU The only thing the other CPUs do in the kernel is pull processes off the run queue and do context switches Simplifies OS design locking is much simpler Common first step in OS conversion for multiprocessor use 18 / 39 13

Symmetric Multiprocessing Each processor can do anything Possible to have more than one CPU in the kernel simultaneously Need fine-grained locking; single big lock is almost the same as asymmetric MP Locking is a very important issue for multiprocessors; we ll discuss this more on Wednesday 19 / 39 Processor Affinity Sometimes, it s better (or necessary) for a given process to execute on a specific CPU Example cited earlier: memory map (and cache) I/O issues sometimes a specific I/O devices is on a local bus 20 / 39 14

How Do We Measure CPU Time? Early clocks were low resolution Unix classic: 60 Hz Too coarse to measure a fraction of a quantum Besides, the clock was an I/O device, hence slow to access 21 / 39 Statistical Time At each clock tick, add 1 to the current process CPU counter Actually, two counters, one for user mode and one for kernel mode Not accurate over short periods: A process may run for too short a time and not get charged A process may start its quantum right before the timer tick and be charged too much Statistically, though, it s good enough 22 / 39 15

I/O and Memory CPU time isn t the only scarce resource Especially today, total system performance is limited by I/O bandwidth and memory availability Must read programs in from disk Must have memory for them That may mean paging out another process, which puts more load on the disk The scheduler should interact with the I/O subsystem and the memory subsystem 23 / 39 Different Schedulers 24 / 39 Scheduler Algorithms Modern systems may have many processes running At this instant, for example, cluster is running 525 processes Even on modern CPUs, we don t want scheduling algorithms that iterate over all processes Linux uses a O(1) scheduler scheduling decisions take constant time, regardless of the number of processes 25 / 39 16

Policy versus Mechanism Put some basic mechanism (or mechanisms) in the kernel Permit user processes to set parameters that control scheduling Simplest example: nice command Solaris permits much more control: three classes of scheduler, and parameters within that class 26 / 39 Solaris Scheduler Scheduler classes: real-time, time-sharing, interactive Parameters: Real-Time priority, quantum Kernel threads (System only) Timesharing priority, priority limit Interactive priority, priority limit Newer versions of Solaris have fair-share scheduling and fixed-priority scheduling 27 / 39 17

Solaris Priorities Priority Quantum New Priority After Sleep 0 200 0 50 5 200 0 50 15 160 5 51... 50 40 40 58 55 40 45 58 59 20 49 59 Higher priority processes get shorter quanta. Process get a lower priority when they use up their quantum, and higher priority after blocking for I/O. 28 / 39 Linux Scheduler Both real-time and priority Real-time scheduling can be round-robin or FCFS Dynamic timeslice (quantum) computation Kernel preemption possible if no locks are held 29 / 39 18

Windows XP Real-time and priority scheduling Priority classes: Real-time, High, Above Normal, Normal, Below Normal, Idle Relative priority within class: Time-critical, Highest, Above Normal, Normal, Below Normal, Idle Effective priority calculated from this matrix Priority lowered on quantum expiration Extra priority boost for process associated with current window Unix can t easily do that the window manager knows nothing of processes 30 / 39 Evaluating Scheduler Algorithms 31 / 39 Algorithm Evaluation First question: what criteria do you want to optimize for? Possibilities include CPU utilization, responsiveness, real-time scheduling, etc. Several ways to do the evaluation 32 / 39 19

Deterministic Modeling Start with a specific workload, i.e., of process CPU demands and arrival times Model them with Gantt charts, as we ve seen Evaluate according to desired metric Simple and fast and only useful for loads that look a lot like what you model 33 / 39 Queueing Theory Start with probability distributions of CPU requests, arrival times, etc. Common assumption: arrivals are distributed according to a Poisson distribution Sample (and simple) result: Let n be the average queue length, W the average queue wait time, and λ the mean interarrival time (regardless of distribution). Then n = λ W 34 / 39 20

Simulation Build a simulator of the scheduling algorithm Feed in simulated inputs and see what happens Simulations can be fed by probability distributions or by trace data from real systems Such trace data is an excellent way to compare two different simulators 35 / 39 Metacomment Trace data is always useful Instruction traces, network packet traces, CPU load traces, etc. Some such datasets become the way to evaluate new schemes 36 / 39 21

Build It and Try It Build a real system and see what happens But what s the load? Real users? If you re lucky, you have trace data to feed in (and a system amenable to such replays) 37 / 39 Limits of Evaluation Load changes Sometimes, load changes because of scheduler changes Example: if a process gets the CPU more quickly after a disk I/O request, it may be able to issue the next requiest within the rotational delay of the disk Conclusion: we need flexible scheduling algorithms that can be tuned at each site 38 / 39 22

Summary Scheduling is a complex matter The criteria and algorithms have changed somewhat, but the problem remains Any time you click on something and it doesn t respond immediately, there s a scheduler problem 39 / 39 23