CPU SCHEDULING CPU SCHEDULING.

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 Chapter 6
Chap 5 Process Scheduling. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
CPU Scheduling Algorithms
Chapter 3: CPU Scheduling
02/06/2008CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 5-CPU Scheduling
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
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
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Chapter 6 CPU SCHEDULING.
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
Chapter 5 CPU Scheduling Bernard Chen Spring 2007.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Process CPUArrival Time P P2 3 0 P3 3 0 The Gantt Chart for the schedule is: Waiting time for P1 = (7-7)=0; P2 = (0-0)=0; P3 = (3-0)
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
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling 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
CPU Scheduling Algorithms
Priority Scheduling Example
Process Scheduling B.Ramamurthy 9/16/2018.
Scheduling (Priority Based)
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
Process Scheduling B.Ramamurthy 11/18/2018.
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating Systems Lecture 15.
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Process Scheduling B.Ramamurthy 12/5/2018.
Chapter5: CPU Scheduling
COT 4600 Operating Systems Spring 2011
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Outline Scheduling algorithms Multi-processor scheduling
CGS 3763 Operating Systems Concepts Spring 2013
Chapter 5: CPU Scheduling
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Process Scheduling B.Ramamurthy 4/19/2019.
Process Scheduling B.Ramamurthy 4/24/2019.
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Process Scheduling B.Ramamurthy 5/7/2019.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Chapter 6: CPU Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Presentation transcript:

CPU SCHEDULING CPU SCHEDULING

Processor Scheduling algorithms The goal of a scheduling algorithm is to select the most appropriate process in the ready queue. For simplicity, we will assume that we have a single I/O server and a single device queue, device queue always implemented with FCFS (FIFO) method. We also will neglect the switching time between processes (context switching).

2.3.1 First-Come-First-Served (FCFS) In this algorithm, the process to be selected is the process which requests the processor first. This is the process whose PCB is at the head of the ready queue. Contrary to its simplicity, its performance may often be poor compared to other algorithms.

2.3.1 First-Come-First-Served (FCFS) FCFS may cause processes with short processor bursts to wait for a long time. If one process with a long processor burst gets the processor, all the others will wait for it to release it and the ready queue will be crowded. This is called the convoy effect.

Process Wait Time : Service Time - Arrival Time Average Wait Time: (0+4+6+13) / 4 = 5.55

FCFS Process Burst Time P1 24 P2 3 P3 3 With FCFS, the process that requests the CPU first is allocated the CPU first Case #1: Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 Average turn-around time: (24 + 27 + 30)/3 = 27 P1 P2 P3 24 27 30

SJF The SJF algorithm associates with each process the length of its next CPU burst When the CPU becomes available, it is assigned to the process that has the smallest next CPU burst (in the case of matching bursts, FCFS is used) Two schemes: Nonpreemptive – once the CPU is given to the process, it cannot be preempted until it completes its CPU burst Preemptive – if a new process arrives with a CPU burst length less than the remaining time of the current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF) Best approach to minimize waiting time. Impossible to implement Processer should know in advance how much time process will take.

Process Arrival Time Burst Time 7 8 12 16

Average waiting time = [0 +(8-2)+(7-4) +(12-5)] /4 =4

Process Wait Time : Service Time - Arrival Time P0 3 - 0 = 3 P1 0 - 0 = 0 P2 16 - 2 = 14 P3 8 - 3 = 5 Average Wait Time: (3+0+14+5) / 4 = 5.50

Preemptive SJF (Shortest-remaining-time-first) Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive, varied arrival times) Average waiting time = ( [(0 – 0) + (11 - 2)] + [(2 – 2) + (5 – 4)] + (4 - 4) + (7 – 5) )/4 = 9 + 1 + 0 + 2)/4 = 3 Average turn-around time = (16 + 7 + 5 + 11)/4 = 9.75 P1 P3 P2 4 2 11 P4 5 7 16

Priority Scheduling Algorithm The SJF algorithm is a special case of the general priority scheduling algorithm A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (smallest integer = highest priority) Priority scheduling can be either preemptive or non-preemptive A preemptive approach will preempt the CPU if the priority of the newly-arrived process is higher than the priority of the currently running process A non-preemptive approach will simply put the new process (with the highest priority) at the head of the ready queue SJF is a priority scheduling algorithm where priority is the predicted next CPU burst time The main problem with priority scheduling is starvation, that is, low priority processes may never execute A solution is aging; as time progresses, the priority of a process in the ready queue is increased

Example Process Burst time Arrival Priority P1 10 0 .0 3 P2 1 0.0 1 Average waiting time = (0 + 1 + 6 + 16 + 18) / 5 = 8.2

Round Robbin In the round robin algorithm, each process gets a small unit of CPU time (a time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units. Performance of the round robin algorithm q large  FCFS q small  q must be greater than the context switch time; otherwise, the overhead is too high One rule of thumb is that 80% of the CPU bursts should be shorter than the time quantum

Process Wait Time : Service Time - Arrival Time P0 (0-0) + (12-3) = 9 P1 (3-1) = 2 P2 6-2) + (15-9) = 10 P3 (9-3) + (18-12) = 12 Average Wait Time: (9+2+10+12) / 4 = 8.25