Scheduling 21 May 2019.

Slides:



Advertisements
Similar presentations
OS, , Part II CPU Scheduling Department of Computer Engineering, PSUWannarat Suntiamorntut.
Advertisements

Operating Systems Chapter 6
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
Chapter 3: CPU Scheduling
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
7/2/2015 Operating Systems Michael Elhadad, Meni Adler& Amnon Meisels 1 Course Syllabus 1. Introduction - History; Views; Concepts; Structure 2.
7/2/2015 Operating Systems, 2012, Danny Hendler & Roie Zivan 1 Course Syllabus 1. Introduction - History; Views; Concepts; Structure 2. Process Management.
CPU-Scheduling Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The short term scheduler.
Chapter 6: CPU Scheduling
Chapter 6 CPU SCHEDULING.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
lecture 5: CPU Scheduling
CPU SCHEDULING.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Chapter 5a: CPU Scheduling
Networks and Operating Systems: Exercise Session 2
CPU Scheduling Shmuel Wimer prepared and instructed by
Uniprocessor Scheduling
Chapter 2 Scheduling.
Chapter 2.2 : Process Scheduling
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
Process Scheduling B.Ramamurthy 9/16/2018.
Scheduling (Priority Based)
Chapter 5: CPU Scheduling
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
CPU Scheduling Basic Concepts Scheduling Criteria
Operating Systems, 2011, Danny Hendler & Amnon Meisels
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Andy Wang Operating Systems COP 4610 / CGS 5765
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Process Scheduling B.Ramamurthy 12/5/2018.
Chapter5: CPU Scheduling
TDC 311 Process Scheduling.
COT 4600 Operating Systems Spring 2011
Chapter 6: CPU Scheduling
CGS 3763 Operating Systems Concepts Spring 2013
Process Scheduling Decide which process should run and for how long
Chapter 5: CPU Scheduling
Course Syllabus 1. Introduction - History; Views; Concepts; Structure
Process Scheduling B.Ramamurthy 2/23/2019.
Processor Scheduling Hank Levy 1.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Process Scheduling B.Ramamurthy 4/24/2019.
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Process Scheduling B.Ramamurthy 5/7/2019.
CPU SCHEDULING CPU SCHEDULING.
Chapter 6: CPU Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
CPU Scheduling CSE 2431: Introduction to Operating Systems
Presentation transcript:

Scheduling 21 May 2019

Intro Interleave the execution of processes to maximize CPU utilization while providing reasonable response time The scheduler determines: Who will run When it will run For how long 21 May 2019

Scheduling algorithms: Terms Response time: minimize, for interactive users Turnaround time: average time for a job to complete Waiting time: minimize the average over processes Throughput: number of completed jobs per time unit 21 May 2019

Scheduling algorithms: Terms Throughput – number of processes completed per unit time Turnaround time – interval of time from process submission to completion Waiting time – sum of time intervals the process spends in the ready queue Response time – the time between submitting a command and the generation of the first output CPU utilization – the percentage of time in which the CPU is not idle 21 May 2019

Criteria by system type 21 May 2019

Scheduling – Types of behavior Bursts of CPU usage alternate with periods of I/O wait CPU-bound processes I/O bound processes 21 May 2019

CPU Utilization vs. Turnaround time We have 5 interactive jobs i1…i5 and one batch job b Interactive jobs: 10% CPU; 20% disk I/O; 70% terminal I/O; total time for each job 10 sec. Batch job: 90% CPU; 10% disk I/O; total time 50 sec. Cannot run all in parallel !! i1..i5 in parallel - disk I/O is 100% utilized b and one i in parallel - CPU is 100% utilized 21 May 2019

CPU utilization vs. Turnaround time Two possible schedules: 1. First i1…i5, then b UT = (10x0.5 + 50x0.9)/60 = 83% TA = (10x5 + 60x1)/6 = 18.33sec. 2. b and each of the i’s (in turn) in parallel: UT = (50x(0.9+0.1))/50 = 100% TA = (10+20+30+40+50+50)/6 = 33sec. 21 May 2019

When are Scheduling Decisions made ? 1. Process switches from Running to Waiting (e.g. I/O) 2. New process created (e.g. fork) 3. Process switches from Running to Ready (clock.. ) 4. Process switches from Waiting to Ready (e.g. IO completion) 5. Process terminates Types of Scheduling: Preemptive scheduling: process preepmtion may be initiated by scheduler When for non-preemptive scheduling? only 1 And 5. 21 May 2019

First-come-first-served (FCFS) scheduling Processes get the CPU in the order they request it and run until they release it Ready processes form a FIFO queue 21 May 2019

FCFS may cause long waiting times Process Burst time (milli) P1 24 P2 3 P3 3 If they arrive in the order P1, P2, P3, we get: 24 27 30 P1 P2 P3 Average waiting time: (0+24+27) / 3 = 17 21 May 2019

FCFS may cause long waiting times (cont’d) Process Burst time (milli) P1 P2 P3 24 3 If they arrive in the order P1, P2, P3, average waiting time 17 What if they arrive in the order P2, P3, P1? 3 30 P1 P2 P3 Average waiting time: 6 (0+3+6) / 3 = 3 21 May 2019

(Non preemptive) Shortest Job First (SJF) scheduling The CPU is assigned to the process that has the smallest next CPU burst In some cases, this quantity is known or can be approximated Process Burst time (milli) A B C 5 2 4 D 1 FCFS schedule C B 5 A Average waiting time: 8.75 7 D 11 12 D A B 1 Average waiting time: 5.75 7 C 12 SJF schedule 3 21 May 2019

Non-preemptive SJF: example (varying arrival times) Process Arrival time Burst time P1 7 P2 2 4 P3 4 1 P4 5 5 Non-preemptive SJF schedule P1 P3 7 8 P2 12 16 P4 2 P2 4 P3 5 P4 Average waiting time: (0+6+3+7) / 4 = 4 21 May 2019

Preemptive SJF (Shortest Remaining Time First) Process Arrival time Burst time P1 7 P2 2 4 P3 4 1 P4 5 5 Preemptive SJF schedule P1 2 P2 P3 5 P2 7 P4 11 16 P1 4 P1(5) P2(2) P4(4) Average waiting time: (9+1+0+2) / 4 = 3 21 May 2019

Round Robin - the oldest method Each process gets a small unit of CPU time (time- quantum), usually 10-100 milliseconds For n ready processes and time-quantum q, no process waits more than (n - 1)q Approaches FCFS when q grows Time-quantum ~ switching time (or smaller) relatively large waste of CPU time Time-quantum >> switching time long response (waiting) times, FCFS 21 May 2019

Compatible Time Sharing System (CTSS) Assign time quanta of different lengths to different priority classes Highest priority class: 1 quantum, 2nd class: 2 quanta, 3rd class: 4 quanta, etc. Move processes that used their quanta to a lower class Net result - longer runs for CPU-bound processes; higher priority for I/O-bound processes for a CPU burst of 100 time quanta - 7 switches instead of 100 (in RR) 21 May 2019

User-level Thread Scheduling Scheduling within a quantum Different scheduling algorithms for threads/processes possible No way to preempt user threads Thread context switch much faster Application-specific scheduling possible 21 May 2019

Kernel-level Thread Scheduling Scheduling within a quantum Scheduler may prefer switches within same process Context switch more expensive A blocking thread does not block all process threads 21 May 2019

Three classes of threads Real-time FIFO Have highest priority, can only be preempted by a higher-priority real-time FIFO thread Real-time round robin Assigned time quantum Timesharing Priorities 100-139 Priority determines the number of clock ticks (jiffys) assigned to a round-robin or timesharing thread 21 May 2019

21 May 2019