Upload
nitish-sandhawar
View
69
Download
0
Embed Size (px)
Citation preview
CPU SCHEDULINGBy- Nitish Kumar SandhawarRoll-52Id- 17049Subject-Operating System
PRIORITY AND ROUND ROBIN
CPU SHEDULING
– CPU scheduling is a process which allows one process to use the CPU while the execution of another process is on hold (in waiting state) due to unavailability of any resources like I/O etc, thereby making full use of CPU. The aim of CPU scheduling is to make the system efficient, fast and fair.
– Scheduling is the method by which work specified by some means is assigned to resources that complete the work.
CPU SCHEDULING CRITERIA
Throughput- Keep the CPU as busy as possible (from 0% to 100%).
CPU utilization-No. of processes that complete their execution per time unit.
Turn Around Time-Amount of time to execute a particular process.Response time-Amount of time it takes from when a
request was submitted until the first response is produced.Waiting time-Amount of time a process has been waiting
in the ready queue.
Different Types of Scheduling Algorithm
There are two types of scheduling algorithm :-1.Preemptivea)Preempted SJF (In some Cases)-also called pre-
emptive SJFb)Preempted Priority (In some Cases)-also called pre-
emptive Priorityc) Round Robind)Multilevel Queue Schedulinge)Multilevel Feedback Queue–
1.Non-Preemptivea)First Come First Serveb)Non-Preempted SJFc) Non-Preempted Priority
PRIORITY
The Priority scheduling algorithm is a general case of the SJF algorithm. It is a non-Preemptive, pre-emptive algorithm and one of the most common scheduling algorithms in batch systems.
Each process is assigned a priority. Process with highest priority is to be executed first and so on. Process with same priority are executed on FCFS basis.
In Priority algorithm priority (p) is the inverse of the given priority value. The larger the numeric value of priority, the lower the priority, and vice versa.
Priority can be decided based on memory requirements, time requirements or any other resource requirements,
–
Wait time of each process is as follows −
Average Wait Time: (9+5+12+0) / 4 = 6.5
Process
Wait Time : Service Time - Arrival Time
P0 9 - 0 = 9P1 6 - 1 = 5P2 14 - 2 = 12P3 0 - 0 = 0
–Advantage- Simplicity Reasonable support for priority Suitable for applications with varying
time and resource requirement. –Disadvantage- Indefinite blocking or starvation. A priority scheduling can leave some
low priority waiting processes indefinitely for CPU.
ROUND ROBIN Round Robin is the preemptive
process scheduling algorithm. Each process is provided a fix time to
execute, it is called a quantum. Once a process is executed for a
given time period, it is preempted and other process executes for a given time period.
Context switching is used to save states of preempted processes.
The Round Robin scheduling is especially designed for time sharing systems.
Wait time of each process is as follows –
Process
Wait Time : Service Time - Arrival Time
P0 (0 - 0) + (12 - 3) = 9P1 (3 - 1) = 2P2 (6 - 2) + (14 - 9) + (20 -
17) = 12P3 (9 - 3) + (17 - 12) = 11
Average Wait Time: (9+2+12+11) / 4 = 8.5
Advantage-• There is fairness since every process gets equal share
of CPU. • The newly created process is added to end of ready
queue. • A round-robin scheduler generally employs time-
sharing, giving each job a time slot or quantum. Disadvantage-• Very important jobs wait in line. • Largest job take enough time for completion. • Setting the quantum too short causes too many context
switches and lower the CPU efficiency. • Setting the quantum too long may cause poor response
time and approximates FCFS.
THANKYOU FOR
YOUR PATIENCE