Job scheduling Queue discipline.

Slides:



Advertisements
Similar presentations
Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Operating Systems Chapter 6
Chap 5 Process Scheduling. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling Algorithms
Chapter 3: CPU Scheduling
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Operating System Process Scheduling (Ch 4.2, )
Operating System I Process Scheduling. Schedulers F Short-Term –“Which process gets the CPU?” –Fast, since once per 100 ms F Long-Term (batch) –“Which.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
02/06/2008CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Scheduling in Batch Systems
Chapter 6: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 6: CPU Scheduling Basic.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
Chapter 5-CPU Scheduling
Operating Systems Process Scheduling (Ch 4.2, )
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Operating System Process Scheduling (Ch 4.2, )
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Basic Concepts Maximum CPU utilization.
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
Chapter 6 CPU SCHEDULING.
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
1 11/29/2015 Chapter 6: CPU Scheduling l Basic Concepts l Scheduling Criteria l Scheduling Algorithms l Multiple-Processor Scheduling l Real-Time Scheduling.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 5: CPU Scheduling Basic.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Processor Scheduling Hank Levy. 22/4/2016 Goals for Multiprogramming In a multiprogramming system, we try to increase utilization and thruput by overlapping.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Introduction to Operating System Created by : Zahid Javed CPU Scheduling Fifth Lecture.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU Scheduling G.Anuradha Reference : Galvin. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
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.
CPU SCHEDULING.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
Presentation transcript:

Job scheduling Queue discipline

Scheduling • Modern computers have many processes/threads that want to run concurrently The scheduler is the manager of the CPU resource • It makes allocation decisions – it chooses to run certain processes over others from the ready queue – Zero threads: just loop in the idle loop – One thread: just execute that thread – More than one thread: now the scheduler has to make a resource allocation decision • The scheduling algorithm determines how jobs are scheduled

• Threads alternate between performing I/O and performing computation • In general, the scheduler runs: – when a process switches from running to waiting – when a process is created or terminated – when an interrupt occurs • In a non-preemptive system, the scheduler waits for a running process to explicitly block, terminate or yield • In a preemptive system, the scheduler can interrupt a process that is running.

Process states Processes are I/O-bound when they spend most of their time in the waiting state Processes are CPU-bound when they spend their time in the ready and running states Time spent in each entry into the running state is called a CPU burst Frequency Burst Duration

Scheduling Evaluation Metrics CPU utilization: % of time the CPU is not idle (r) Throughput: completed processes per unit time Turnaround time: submission to completion (R) Waiting time: time spent on the ready queue (W) The right metric depends on the context

Evaluating Scheduling Algorithms Queueing theory Mathematical techniques Uses probablistic models of jobs / CPU utilization Simulation Probabilistic(e.g. Taylor) or trace-driven Deterministic methods / Gantt charts Use more realistic workloads

First-Come, First-Served Process A B C Burst Time 8 1 8 9 10 A B C Gantt Chart Avg Wait Time (0 + 8 + 9) / 3 = 5.7

FCFS(FIFO) and LCFS(LIFO) Problems with FCFS Average waiting time can be large if small jobs wait behind long ones (convoy effect) May lead to poor overlap of I/O and CPU time Problems with LCFS May lead to starvation – early processes may never get the CPU

Shortest Job First (SJF) long short – Choose the job with the shortest next CPU burst – Provably optimal for minimizing average waiting time

Shortest Job First 1 2 10 A B C Process A B C Burst Time 8 1 1 2 10 A B C Avg Wait Time (0 + 1 + 2) / 3 = 1

SFJ Variants Two Schemes: i) Non-Preemptive -- Once CPU given to the job, it cannot be preempted until it completes its CPU burst. ii) Preemptive -- If a new job arrives with CPU burst length shorter than remaining time of the current executing job -- preempt. (Shortest remaining time first or SRPT)

Example of Non-Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (non-preemptive) P1 P3 P2 7 3 16 P4 8 12 Average waiting time = (0 + 6 + 3 + 7)/4 = 4

Preemptive SJF (SRPT) SJF (preemptive) Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive) P1 P3 P2 4 2 11 P4 5 7 16 Average waiting time = (9 + 1 + 0 +2)/4 = 3

Problems with SJF Impossible to predict CPU burst times Schemes based on previous history (e.g. exponential averaging) SJF may lead to starvation of long jobs Solution to starvation- Age processes: increase priority as a function of waiting time

Priority Scheduling 1 9 10 A B C SJF is a special case Process A B C Burst Time 8 1 Priority 2 1 3 1 9 10 A B C Avg Wait Time (0 + 1 + 9) / 3 = 3.3

Priority Scheduling Criteria? Internal open files memory requirements CPU time used - time slice expired (RR) process age - I/O wait completed External $ department sponsoring work process importance super-user (root) - nice

Round robin (RR) Often used for timesharing Ready queue is treated as a circular queue (FIFO) Each process is given a time slice called a quantum (q) – It is run for the quantum or until it finishes – RR allocates the CPU uniformly (fairly) across all participants. If average queue length is n, each participant gets 1/n

Example of Round Robin (q=8) Process P1 P2 P3 P4 P5 P6 P7 Burst Time 10 6 23 9 31 3 19 Wait Times 41 8 60 51 70 38 75 2 41 8 15 7 14 29 17 1 22 29 23 15 7 30 22 15 3 38 11 3 41 19 15 P1 8 P2 6 P3 8 P4 8 P5 8 P6 3 P7 8 P1 2 P3 8 P4 1 P5 8 P7 8 P3 7 P5 8 P7 3 343 / 7 = 49.00 P5 7

Round Robin Fun Wait time? Process A B C Burst Time 10 q = 10 q = 1 As the time quantum grows, RR becomes FCFS Smaller quanta are generally desirable, because they improve response time • Problem: Overhead of frequent context switch As q  0, we get processor sharing (PSRR)

Fun with Scheduling Process A B C Burst Time 10 1 2 Priority 2 1 3 Gantt Charts: FCFS SJF Priority RR (q=1) Performance: Throughput Waiting time Turnaround time

Multi-Level Queues ... System Interactive Batch Ready queue is partitioned into separate queues. System Priority 1 Priority 2 Priority 3 Interactive Batch ... Each queue has its own scheduling algorithm. Scheduling must be done between the queues

MQ-Fixed Priority Scheduling Queues A, B, C... Serve all from A then from B... If serving queue B and process arrives in A, then start serving A again: i1) Preemptive -- As soon as processes arrive in A (preempt, if serving from B) i2) Non-preemptive -- Wait until process from B finishes starvation is possible -- processes do not move between queues

MQ-Time Slice Allocation Each queue gets a certain amount of CPU time which it can schedule amongst its processes Example 80% to foreground in RR 20% to background in FCFS

Linux Process Scheduling Two classes of processes: Real-Time Normal Real-Time: Always run Real-Time above Normal Round-Robin or FIFO “Soft” not “Hard”

Linux Process Scheduling Normal: Credit-Based process with most credits is selected time-slice then lose a credit (0, then suspend) no runnable process (all suspended), add to every process: credits = credits/2 + priority Automatically favors I/O bound processes

Windows NT Scheduling Basic scheduling unit is a thread Priority based scheduling per thread Preemptive operating system No shortest job first, no quotas

Priority Assignment NT kernel uses 31 priority levels 31 is the highest; 0 is system idle thread Realtime priorities: 16 - 31 Dynamic priorities: 1 - 15 Users specify a priority class: realtime (24) , high (13), normal (8) and idle (4) and a relative priority: highest (+2), above normal (+1), normal (0), below normal (-1), and lowest (-2) to establish the starting priority Threads also have a current priority

Quantum Determines how long a Thread runs once selected Varies based on: NT Workstation or NT Server Intel or Alpha hardware Foreground/Background application threads How do you think it varies with each?