CPU Scheduling G.Anuradha References : Galvin and William Stallings Problems taken from Principles of OS by Naresh Chauhan.

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
Advertisements

 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.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
CPU Scheduling CS 3100 CPU Scheduling1. Objectives To introduce CPU scheduling, which is the basis for multiprogrammed operating systems To describe various.
Chapter 3: CPU Scheduling
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
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
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 8 Chapter 5: CPU Scheduling.
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
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
Chapter 6 CPU SCHEDULING.
Operating System Principles Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
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.
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 ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
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 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.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5a: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Chapter5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Presentation transcript:

CPU Scheduling G.Anuradha References : Galvin and William Stallings Problems taken from Principles of OS by Naresh Chauhan

Objectives To introduce CPU scheduling, which is the basis for multiprogrammed operating systems. To describe various CPU-scheduling algorithms. To discuss evaluation criteria for selecting a CPU-scheduling algorithm for a particular system. To examine the scheduling algorithms of several operating systems.

Basic concepts-CPU –I/O Burst cycle Why Multi programming? – To Maximize CPU utilization CPU Scheduling is central to OS design For proper CPU scheduling the histogram of CPU-Burst duration is considered.

Frequency for shorter duration is much more than the frequency of longer duration This is the general trend

Types of Scheduler Long-term Scheduler:-Needed only in the case of batch processing and is absent in multi user time- sharing system. In time-sharing systems the jobs are directly entered into ready queue. Short-term Scheduler:-Invoked whenever there is an interrupt, to select another process for execution. Medium-term Scheduler:- Invoked when there is a need to swap out some blocked processes from memory to secondary storage.

Preemptive Scheduling Circumstances when CPU-Scheduling Decisions may take place – Process switches from running state to waiting state (I/O, termination of child process) – Process switches from running to ready state(interrupt) – Process switches from waiting state to ready state(Completion of I/O) – Process terminates Preemptive Scheduling Non Preemptive Scheduling

What are the factors affecting preemptive scheduling? Cost associated with access to shared data. Cooperative process Affects the design of os kernel

Role of dispatcher Switching context Switching to user mode Jumping to the proper location in the user program to restart the program Dispatch Latency is the time taken to stop one process and start another running process.

Scheduling Criteria CPU Utilization Throughput: Number of processes completed per unit time Turnaround time: the interval from the time of submission of a process to the time of completion Turnaround time= waiting time+ execution time

Waiting time: sum of periods spend waiting in the ready queue Response time:- time taken to start responding Maximize CPU utilization, Maximize throughput, minimize turnaround time, waiting time and response time.

Scheduling Algorithms First Cum First Served Scheduling(FCFS) Shortest job First(SJF) Shortest Remaining Time Next(SRTN) Round Robin(RR) Multilevel Queue Scheduling

First Cum First Served (FCFS)

If process come in the order P3, P2, P1 find the average waiting time.

Waiting time for P1=0Average Execution time=(5+3+2)/3=3.33 Waiting time for P2=5 Waiting time for P3=8 Average Waiting time=(0+5+8)/3=4.33 Average Turn Around time=Average Waiting time + Average Execution time = =7.66 Average Response time=(0+5+8)/3=4.33

Features of FCFS Average waiting time under FSFS varies if the CPU burst times vary greatly Convey effect is produced because of CPU and IO bound processes FCFS is non preemptive.

Solve Average Waiting time Average Execution time Average Turn Around time Average Response time

Shortest Job First

Average Execution time=(5+3+2)/3=3.33 Average Turn Around Time= =5.66 Average Response time=(0+2+5)/3=2.33

Solve Average Waiting time Average Execution time Average Turn Around time Average Response time

Difficulties in SJF algorithm Optimal. The length of the next CPU request is not known in advance The burst time of the next process can be predicted. The predicted value for the next CPU burst is depended on recent information tn and past history SJF can be preemptive or nonpreemptive. Preemptive SJF is called as Shortest remaining time first scheduling

Shortest Remaining Time First Scheduling ProcessArrival TimeBurst Time P108 P214 P329 P435 P1P2P4P1P WT of P1=(10-1)=9 WT of P2=0 WT of P3=(17-2)=15 WT of P4=(5-3)=2 Average WT=( )/4=6.5ms Average Execution Time=( )/5=6.5 ATAT= =13ms

STF ProcessArrival TimeBurst Time P108 P214 P329 P435 P1P2P4P WT for P1=0 WT for P2=(8-1)=7 WT for P3=(17-2)=15 WT for P4=(12-3)=9 Average WT=( )/4=7.75 ATAT= =14.25ms

Solve(SJF and SRTF) ProcessArrival TimeBurst Time P109 P215 P323 P434

Priority Scheduling All process arrive at time t=0 ProcessBurst TimePriority P1103 P211 P324 P415 P552 P2P5P1P4P

Priority Scheduling ProcessBurst TimePriorityWTTTNormalized TT P P P P P All process arrive at time t=0

Priority Scheduling(PS) Contd… PS can be – Internal: use measurable quantity to compute priority, like time limits, memory requirements, number of open files, etc. – External: Importance of process, type and amount of funds paid for computer use PS can be either – Preemptive: – Non Preemptive:

Starvation Why starvation happens? – When low priority job waits indefinitely Solution to starvation is aging – Increasing the priority of processes that wait in the system for long time

Round Robin Scheduling Designed for time sharing systems Preemption added to FCFS is Round Robin Scheduling Ready queue is circular queue

ProcessBurst time P15 P23 P32 WT for P1=((3-1)+(6-4)+(8-7)=5 ET for P1=5 WT for P2=((1-0)+((4-2)+(7-5)=5 ET for P2=3 WT for P3=(2-0)+(5-3)=4 ET for P3=2 Avg. WT=4.67Avg ET=3.34 ATAT=8.01

Comparision with FCFS Compute the same problem using FCFS and comment on the average turnaround time Reason out the change

Reasoning of RR RR is heavily depended on time quantum Lesser the time quantum, more the context switches Turnaround time also depends on the size of the time quantum. If time quantum is large enough then RR degenerates to FCFS Thumb rule : 80% of cpu bursts should be shorter than the time quantum.

ProcessBTPriority P1103 P211 P323 P414 P552 The processes are assumed to have arrived in the order P1,p2,p3,p4,p5 1.Draw Gantt chart for FCFS, SJF, nonpremptive priority, RR(Time slice=1) 2.TT of each process the above scheduling algos 3.WT of each process for the above scheduling algos 4.Which algo has minimum average waiting time

Multilevel queue scheduling Based on foreground(interactive) processes and background (batch) processes multilevel queue scheduling partitions ready queues into several queues. Each queue has its own scheduling algorithm. scheduling among the queues, implemented as fixed-priority preemptive scheduling.

Example of multilevel queue scheduling

Multilevel Feedback Queue Scheduling Allows a process to move between queues. Uses the concept of aging to prevent starvationaging

Parameters of multilevel queue The number of queues The scheduling algorithm for each queue The method used to determine when to upgrade a process to a higher priority queue The method used to determine when to demote a process to a lower priority queue The method used to determine which queue a process will enter when that process needs service

Operating System Examples LINUX Windows Solaris

LINUX

Windows Scheduling Uses priority-based preemptive scheduling 32-level priority scheme is used for scheduling Variable class has priority from 1 to 15 and real time class has priority 16 to 31 Windows API has 6 priority classes – IDLE PRIORITY CLASS – BELOW NORMAL PRIORITY CLASS – NORMAL PRIORITY CLASS – ABOVE NORMAL PRIORITY CLASS – HIGH PRIORITY CLASS – REALTIME PRIORITY CLASS

Solaris Scheduling Uses priority based thread scheduling Each thread belongs to one of six classes: Time sharing (TS) (default) Interactive (IA) Real time (RT) System (SYS) Fair share (FSS) Fixed priority (FP)

Solaris Scheduling Contd… dynamically alters priorities and assigns time slices of different lengths using a multilevel feedback queue The higher the priority, the smaller the time slice; and the lower the priority, the larger the time slice. Interactive processes have a higher priority; CPU-bound processes, a lower priority.

RECAP Types of schedulers Types of scheduling algos Examples of schedulers in different os