Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

Similar documents
Today s class. Scheduling. Informationsteknologi. Tuesday, October 9, 2007 Computer Systems/Operating Systems - Class 14 1

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 5: CPU Scheduling

Uniprocessor Scheduling. Aim of Scheduling

Uniprocessor Scheduling. Aim of Scheduling. Types of Scheduling. Long-Term Scheduling. Chapter 9. Response time Throughput Processor efficiency

LECTURE 3:CPU SCHEDULING

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

CS370 Operating Systems

Multiprocessor and Real-Time Scheduling. Chapter 10

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

CPU Scheduling: Objectives

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

Multiprocessor and Real- Time Scheduling. Chapter 10

CPU Scheduling Algorithms

Chapter 5 CPU scheduling

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

Chapter 5: CPU Scheduling

Scheduling of processes

Chapter 9 Uniprocessor Scheduling

Chapter 9. Uniprocessor Scheduling

Uniprocessor Scheduling. Chapter 9

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

Uniprocessor Scheduling

Properties of Processes

Chapter 6: CPU Scheduling

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

CS370 Operating Systems

Chapter 5: CPU Scheduling

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

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts

LAST LECTURE ROUND-ROBIN 1 PRIORITIES. Performance of round-robin scheduling: Scheduling Algorithms: Slide 3. Slide 1. quantum=1:

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

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

CS307: Operating Systems

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Chapter 5: Process Scheduling

CHAPTER 2: PROCESS MANAGEMENT

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM.

Course Syllabus. Operating Systems

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Operating Systems CS 323 Ms. Ines Abbes

CS3733: Operating Systems

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

Operating System Concepts Ch. 5: Scheduling

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

ECE519 Advanced Operating Systems

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

Scheduling. The Basics

CSE 4/521 Introduction to Operating Systems

Last Class: Processes

Chapter 6: CPU Scheduling

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 5: Process Scheduling

CS370 Operating Systems

Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

CPU Scheduling (1) CPU Scheduling (Topic 3) CPU Scheduling (2) CPU Scheduling (3) Resources fall into two classes:

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 6: CPU Scheduling

Operating Systems ECE344. Ding Yuan

Lecture Topics. Announcements. Today: Advanced Scheduling (Stallings, chapter ) Next: Deadlock (Stallings, chapter

Chapter 6: CPU Scheduling

Ch 4 : CPU scheduling

Multiprocessor scheduling

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Scheduling. Today. Next Time Process interaction & communication

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Chapter 5 Process Scheduling

Operating Systems Unit 3

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

Lecture 2 Process Management

Practice Exercises 305

Operating Systems. Scheduling

COSC243 Part 2: Operating Systems

by Maria Lima Term Paper for Professor Barrymore Warren Mercy College Division of Mathematics and Computer Information Science

Operating System Review Part

Job Scheduling. CS170 Fall 2018

TDIU25: Operating Systems II. Processes, Threads and Scheduling

CS370 Operating Systems

CSE 120 Principles of Operating Systems Spring 2017

Example: CPU-bound process that would run for 100 quanta continuously 1, 2, 4, 8, 16, 32, 64 (only 37 required for last run) Needs only 7 swaps

CS 318 Principles of Operating Systems

3. CPU Scheduling. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

But this will not be complete (no book covers 100%) So consider it a rough approximation Last lecture OSPP Sections 3.1 and 4.1

Titolo presentazione. Scheduling. sottotitolo A.Y Milano, XX mese 20XX ACSO Tutoring MSc Eng. Michele Zanella

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

CS418 Operating Systems

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

Start of Lecture: February 10, Chapter 6: Scheduling

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

Scheduling. CSC400 - Operating Systems. 7: Scheduling. J. Sumey. one of the main tasks of an OS. the scheduler / dispatcher

8: Scheduling. Scheduling. Mark Handley

Assignment 3 (Due date: Thursday, 10/15/2009, in class) Part One: Provide brief answers to the following Chapter Exercises questions:

Scheduling in the Supermarket

CSL373: Lecture 6 CPU Scheduling

Transcription:

Uniprocessor Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Three level scheduling 2 1

Types of Scheduling 3 Long- and Medium-Term Schedulers Long-term scheduler Determines which programs are admitted to the system (ie to become processes) requests can be denied if e.g. thrashing or overload Medium-term scheduler decides when/which processes to suspend/resume Both control the degree of multiprogramming More processes, smaller percentage of time each process is executed 4 2

Short-Term Scheduler Decides which process will be dispatched; invoked upon Clock interrupts I/O interrupts Operating system calls Signals Dispatch latency time it takes for the dispatcher to stop one process and start another running; the dominating factors involve: switching context selecting the new process to dispatch 5 CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait. A process may be CPU-bound IO-bound 6 3

Scheduling Criteria- Optimization goals CPU utilization keep CPU as busy as possible Throughput # of processes that complete their execution per time unit Response time amount of time it takes from when a request was submitted until the first response is produced (execution + waiting time in ready queue) Turnaround time amount of time to execute a particular process (execution + all the waiting); involves IO schedulers also Fairness - watch priorities, avoid starvation,... Scheduler Efficiency - overhead (e.g. context switching, computing priorities, ) 7 Decision Mode Nonpreemptive Once a process is in the running state, it will continue until it terminates or blocks itself for I/O Preemptive Currently running process may be interrupted and moved to the Ready state by the operating system Allows for better service since any one process cannot monopolize the processor for very long 8 4

First-Come-First-Served (FCFS) 0 5 10 15 20 A B C D E non-preemptive Favors CPU-bound processes A short process may have to wait very long before it can execute (convoy effect) 9 Round-Robin 0 5 10 15 20 A B C D E preemption based on clock (interrupts on time slice or quantum -q- usually 10-100 msec) fairness: for n processes, each gets 1/n of the CPU time in chunks of at most q time units Performance q large FIFO q small overhead can be high due to context switches 10 5

Shortest Process First 0 5 10 15 20 A B C D E Non-preemptive Short process jumps ahead of longer processes Avoid convoy effect 11 Shortest Remaining Time First 0 5 10 15 20 A B C D E Preemptive (at arrival) version of shortest process next 12 6

On SPF Scheduling gives high throughput gives minimum (optimal) average response (waiting) time for a given set of processes Proof (non-preemptive): analyze the summation giving the waiting time must estimate processing time (next cpu burst) Can be done automatically (exponential averaging) If estimated time for process (given by the user in a batch system) not correct, the operating system may abort it possibility of starvation for longer processes 13 Determining Length of Next CPU Burst Can be done by using the length of previous CPU bursts, using exponential averaging. 1. t n = actual lenght of n 2. τ n + 1 = predicted value for 3. α, 0 α 1 4. Define τ = α: t + n= 1 n 1 ( α ) τ. n th CPU burst the next CPU burst 14 7

On Exponential Averaging α =0 τ n+1 = τ n history does not count, only initial estimation counts α =1 τ n+1 = t n Only the actual last CPU burst counts. If we expand the formula, we get: τ n+1 = α t n +(1 - α) α t n -1 + +(1 - α ) j α t n -i + +(1 - α ) n τ 0 Since both α and (1 - α) are less than or equal to 1, each successive term has less weight than its predecessor. 15 Priority Scheduling: General Rules Scheduler can choose a process of higher priority over one of lower priority can be preemptive or non-preemptive can have multiple ready queues to represent multiple level of priority Example Priority Scheduling: SPF, where priority is the predicted next CPU burst time. Problem Starvation low priority processes may never execute. A solution Aging as time progresses increase the priority of the process. 16 8

Priority Scheduling Cont. : Highest Response Ratio Next (HRRN) 0 5 10 15 20 1 2 3 4 5 time spent waiting + expected service time expected service time Choose next process with highest ratio non-preemptive no starvation (aging employed) favours short processes 17 overhead can be high Priority Scheduling Cont. : Multilevel Queue Ready queue is partitioned into separate queues, eg foreground (interactive) background (batch) Each queue has its own scheduling algorithm, eg foreground RR background FCFS Scheduling must be done between the queues. Fixed eg., serve all from foreground then from background. Possible starvation. Another solution: Time slice each queue gets a fraction of CPU time to divide amongst its processes, eg. 80% to foreground in RR 20% to background in FCFS 18 9

Multilevel Feedback Queue A process can move between the various queues; aging can be implemented this way. scheduler parameters: number of queues scheduling algorithm for each queue method to upgrade a process method to demote a process method to determine which queue a process will enter first 19 Multilevel Feedback Queues 20 10

Fair-Share Scheduling extention of multi-level queues with feedback + priority recomputation application runs as a collection of processes (threads) concern: the performance of the application, user-groups, (ie. group of processes/threads) scheduling decisions based on process sets rather than individual processes eg. traditional (BSD, ) unix sheduling 21 Real-Time Scheduling 11

Real-Time Systems Tasks or processes attempt to interact with outside-world events, which occur in real time ; process must be able to keep up, e.g. Control of laboratory experiments, Robotics, Air traffic control, Drive-bywire systems, Tele/Data-communications, Military command and control systems Correctness of the RT system depends not only on the logical result of the computation but also on the time at which the results are produced i.e. Tasks or processes come with a deadline (for starting or completion) Requirements may be hard or soft 23 Periodic Real-TimeTasks: Timing Diagram 24 12

E.g. Multimedia Process Scheduling A movie may consist of several files 25 E.g. Multimedia Process Scheduling (cont) Periodic processes displaying a movie Frame rates and processing requirements may be different for each movie (or other process that requires time guarantees) 26 13

Scheduling in Real-Time Systems Schedulable real-time system Given m periodic events event i occurs within period P i and requires C i seconds Then the load can only be handled if Utilization = m i= 1 Ci P i 1 27 VI!!! Scheduling with deadlines: Earliest Deadline First Set of tasks with deadlines is schedulable (i.e can be executed in a way that no process misses its deadline) iff EDF is a schedulable (aka feasible) sequence. Example sequences: 28 14

Rate Monotonic Scheduling Assigns priorities to tasks on the basis of their periods Highest-priority task is the one with the shortest period 29 EDF or RMS? (1) 30 15

EDF or RMS? (2) Another example of real-time scheduling with RMS and EDF 31 EDF or RMS? (3) RMS accomodates task set with less utilization m Ci 10.7 P i= 1 i (recall: for EDF that is up to 1) RMS is often used in practice; main reason: stability is easier to meet with RMS; priorities are static, hence, under transient period with deadline-misses, critical tasks can be saved by being assigned higher (static) priorities it is ok for combinations of hard and soft RT tasks 32 16

Multiprocessor Scheduling Multiprocessors Definition: A computer system in which two or more CPUs share full access to a common RAM 34 17

Multiprocessor Hardware (ex.1) Bus-based multiprocessors 35 Multiprocessor Hardware (ex.2) UMA (uniform memory access) Multiprocessor using a crossbar switch 36 18

Multiprocessor Hardware (ex.3) NUMA (non-uniform memory access) Multiprocessor Characteristics 1. Single address space visible to all CPUs 2. Access to remote memory via commands - LOAD - STORE 3. Access to remote memory slower than to local 37 Design issues (1): Who executes the OS/scheduler(s)? Master/slave architecture: Key kernel functions always run on a particular processor Master is responsible for scheduling; slave sends service request to the master Disadvantages Failure of master brings down whole system Master can become a performance bottleneck Peer architecture: Operating system can execute on any processor Each processor does self-scheduling New issues for the operating system Make sure two processors do not choose the same process 38 19

Master-Slave multiprocessor OS Bus 39 Non-symmetric Peer Multiprocessor OS Bus Each CPU has its own operating system 40 20

Symmetric Peer Multiprocessor OS Bus Symmetric Multiprocessors SMP multiprocessor model 41 Scheduling in Multiprocessors Recall: Tightly coupled multiprocessing (SMPs) Processors share main memory Controlled by operating system Different degrees of parallelism Independent and Coarse-Grained Parallelism no or very limited synchronization can by supported on a multiprocessor with little change (and a bit of salt ) Medium-Grained Parallelism collection of threads; usually interact frequently Fine-Grained Parallelism Highly parallel applications; specialized and fragmented area 42 21

Design issues 2: Assignment of Processes to Processors Per-processor ready-queues vs global ready-queue Permanently assign process to a processor; Less overhead A processor could be idle while another processor has a backlog Have a global ready queue and schedule to any available processor can become a bottleneck Task migration not cheap 43 Multiprocessor Scheduling: per partition RQ Space sharing multiple threads at same time across multiple CPUs 44 22

Multiprocessor Scheduling: Load sharing / Global ready queue Timesharing note use of single data structure for scheduling 45 Multiprocessor Scheduling Load Sharing: a problem Problem with communication between two threads both belong to process A both running out of phase 46 23

Design issues 3: Multiprogramming on processors? Experience shows: Threads running on separate processors (to the extend of dedicating a processor to a thread) yields dramatic gains in performance Allocating processors to threads ~ allocating pages to processes (can use working set model?) Specific scheduling discipline is less important with more than on processor; the decision of distributing tasks is more important 47 Gang Scheduling Solution to prev. problem : 1. Groups of related threads scheduled as a unit (a gang) 2. All members of gang run simultaneously on different timeshared CPUs 3. All gang members start and end time slices together 48 24

Gang Scheduling: another option 49 Multiprocessor Thread Scheduling Dynamic Scheduling Number of threads in a process are altered dynamically by the application Programs (through thread libraries) give info to OS to manage parallelism OS adjusts the load to improve use Or os gives info to run-time system about available processors, to adjust # of threads. i.e dynamic vesion of partitioning: 50 25

Summary: Multiprocessor Thread Scheduling Load sharing: processors/threads not assigned to particular processors load is distributed evenly across the processors; needs central queue; may be a bottleneck preemptive threads are unlikely to resume execution on the same processor; cache use is less efficient Gang scheduling: Assigns threads to particular processors (simultaneous scheduling of threads that make up a process) Useful where performance severely degrades when any part of the application is not running (due to synchronization) Extreme version: Dedicated processor assignment (no multiprogramming of processors) 51 Scheduling and synchronization Priorities + blocking synchronization may result in: priority inversion: low-priority process P holds a lock, highpriority process waits, medium priority processes do not allow P to complete and release the lock fast (scheduling less efficient). To cope/avoid this: use priority inheritance use non-blocking synchronization (wait-free, lock-free, optimistic synchronization; see some ptrs at the course s home page) convoy effect: processes need a resource for short time, the process holding it may block them for long time (hence, poor utilization) non-blocking synchronization is good here, too 52 26