SlideShare a Scribd company logo
SCHEDULING
CA1
Name- Sarupya Datta Sub- Operating System
Roll No.- 13000121089 Code- PCC-CS502
Stream- CSE Sec- B
Registration No.- 211300100110097
INTRODUCTION
• CPU scheduling in operating systems is the process of determining which process or task should have access
to the CPU (Central Processing Unit) at any given time. The scheduler makes this decision based on
predefined algorithms and policies, with the goal of optimizing system performance, responsiveness, and
resource utilization. CPU scheduling enables multitasking, allowing multiple processes to run concurrently
and share the CPU's processing time, leading to efficient execution of tasks and a smooth user experience .
• There are different CPU scheduling algorithms, but here we are going to discuss only those
two type which are related to our assignment–
 SRTF
 FCFS
Shortest RemainingTime First Algorithm
(SRTF)
• Shortest Time Remaining First (STRF) is a CPU scheduling algorithm used in operating
systems. In STRF, the operating system selects the process with the smallest remaining burst
time (time required to complete its execution) to execute next.
• This ensures that the process with the least amount of work remaining is given priority.
• STRF aims to minimize the average waiting time and turnaround time for processes, making
it an efficient scheduling algorithm for certain scenarios, particularly when dealing with
short tasks.
• It is a preemptive variant of Shortest Job Next (SJN) scheduling.
• Mode -> preemptive
• Criteria -> Burst time(B.T)
Numericals
• Q1). Consider a uniprocessor system, where three processes (Process ID 1, 2, 3 respectively) are there. Arrival
time of the three processes are last 3 digits of your registration number (i.e. if your registration number is
201300100110019, arrival time of P1=0, P2=1, P3=9). Burst time of process 1 is the addition of date (dd, i.e. if
21/07/2003 is Date of Birth, then it is 2+1 = 3), process 2 is addition of month (mm, if July then 0+7, i.e. 7),
and process 3 is addition of last two digit of the year (yy, if 2003 then 0+3, i.e. 3, if it is 2000 then take first 2
digit). Assume that CPU is using Shortest remaining time first algorithm.
i. Calculate Waiting time of each of the process
ii. Calculate turnaround time of each of the process.
iii. Calculate the percentage of time CPU remains idle.
Sol-
• Priority:- Shortest Remaining Time First (SRTF)
• To Calculate:- 1) Waiting time of each process.
2) Turn around time of each of the process.
3) Percentage of time CPU remains idle.
• Registration no. 211300100110097
• Date of Birth- 02/03/2003
Processors Arrival Burst
P1 0 2
P2 9 3
P3 7 3
PROCESS
ID
ARRIVAL
TIME
(AT)
BURST
TIME
(BT)
COMPLETION
TIME
(CT)
Turn
Around
Time
(CT-AT)
WAITING
TIME
(TAT-BT)
P1 0 2 2 2 0
P2 9 3 13 4 1
P3 7 3 10 3 0
P1 --- P3 P2
0 2 7 10 13
GANTT CHART:-
i) Calculated Waiting time of each of the process:- P1=0
P2=1
P3=0
ii) Calculated Turn-around Time of each of the process:- P1=2
P2=4
P3=3
iii) Calculate the percentage of time CPU remains idle:-
(Total idle time of CPU/ Total time take for competition of whole process)*100
= (5/13)*100
= 38.46 %
FCFS
• First Come First Serve (FCFS) is a non-preemptive CPU scheduling algorithm used in operating systems.
• In FCFS, processes are executed in the order they arrive in the ready queue .
• The process that arrives first is the first to be allocated the CPU, and it continues running until it completes
its execution or enters a waiting state. Only when the first process finishes, the next process in the queue is
executed, and this process continues until all processes are completed.
• FCFS operates on a first-come, first-served basis, without any consideration of the length of the processes or
their priority.
• While FCFS is easy to implement and ensures fairness, it may lead to long average waiting times, especially
if longer processes arrive first and block shorter ones from executing.
• Criteria:- Arrival Time(A.T)
• Mode:-Non-preemptive
• FCFS is not the most efficient scheduling algorithm and may not be suitable for scenarios with varying
process execution times.
Q2) Consider a uniprocessor system, where there exist three processes (Process ID 1, 2, 3 respectively). CPU assigns priority
of the processes based on highest waiting time of the processes present at that time after every 2-unit time. In any process
terminates before the interval time then the default situation will be FCFS scheduling. Each of the process will arrive based
on the last 3 digits of your university roll number. (If Roll No. is 13000118137, arrival time of P0 =1, P1=3, P2=7). CPU
Burst time will be first three digits of your mobile number (i.e. if your mobile number is 8756540439, CPU burst time of
P1=8, P2=7, P3=5, if any number is 0, then take next non zero value from your mobile number like 7000312867, CPU burst
time of P1=7, P2=3, P3=1).
i. Calculate Average Waiting Time.
ii. Calculate Average Turnaround Time.
iii. Calculate the percentage of time CPU remains idle
Sol-
Priority:-
Highest waiting time after every 2 unit of time interval
FCFS(Default: If any process terminates before the interval )
To Calculate:-
i. Average Waiting Time
ii. Average turn around Time
iii. Percentage of time CPU remains idle
University roll number : 13000121089
Mobile number : 7003072392
Process Arrival Time Burst Time
P1 0 7
P2 8 3
P3 9 7
PROCESS
ID
ARRIVAL
TIME
(AT)
BURST
TIME
(BT)
COMPLETION
TIME
(CT)
Turn Around Time
(CT-AT)
WAITING
TIME
(TAT-BT)
P1 0 7 7 7 0
P2 8 3 13 5 2
P3 9 7 18 9 2
P1 P1 P1 P1 ----- P2 P3 P2 P3
0 2 4 6 7 8 10 12 13 18
i) Calculate Average Waiting Time: (WT of P1 + WT of P2 + WT of P3 )/3
= (0 + 2 + 2)/3
= 4/3
= 1.33 %
ii) Calculate Average Turnaround Time : (TAT of P1 + TAT of P2 + TAT of P3)/3
= (7 + 5 + 9)/3
= 21/3
= 7 %
iii) Calculate the percentage of time CPU remains idle : (Total idle time of CPU/ Total time take for competition of whole process)*100
= 1/18 * 100
= 5.55 %
Conclusion
Scheduling algorithms tell the CPU which will be the next process to have CPU time. The main goal
of scheduling algorithms in OS is to Maximize Throughput. Scheduling algorithms can be preemptive
and non-preemptive.
Thank You

More Related Content

Similar to Priority Scheduling.pptx

Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 
Ch6
Ch6Ch6
Ch6
C.U
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
Rushdi Shams
 

Similar to Priority Scheduling.pptx (20)

Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
Document 14 (6).pdf
Document 14 (6).pdfDocument 14 (6).pdf
Document 14 (6).pdf
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 
Fcfs and sjf
Fcfs and sjfFcfs and sjf
Fcfs and sjf
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Introduction to shortest job first scheduling
Introduction to shortest job first schedulingIntroduction to shortest job first scheduling
Introduction to shortest job first scheduling
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Ch6
Ch6Ch6
Ch6
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Comparision of different Round Robin Scheduling Algorithm using Dynamic Time ...
Comparision of different Round Robin Scheduling Algorithm using Dynamic Time ...Comparision of different Round Robin Scheduling Algorithm using Dynamic Time ...
Comparision of different Round Robin Scheduling Algorithm using Dynamic Time ...
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
 

Recently uploaded

Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
Toll tax management system project report..pdf
Toll tax management system project report..pdfToll tax management system project report..pdf
Toll tax management system project report..pdf
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 

Priority Scheduling.pptx

  • 1. SCHEDULING CA1 Name- Sarupya Datta Sub- Operating System Roll No.- 13000121089 Code- PCC-CS502 Stream- CSE Sec- B Registration No.- 211300100110097
  • 2. INTRODUCTION • CPU scheduling in operating systems is the process of determining which process or task should have access to the CPU (Central Processing Unit) at any given time. The scheduler makes this decision based on predefined algorithms and policies, with the goal of optimizing system performance, responsiveness, and resource utilization. CPU scheduling enables multitasking, allowing multiple processes to run concurrently and share the CPU's processing time, leading to efficient execution of tasks and a smooth user experience . • There are different CPU scheduling algorithms, but here we are going to discuss only those two type which are related to our assignment–  SRTF  FCFS
  • 3. Shortest RemainingTime First Algorithm (SRTF) • Shortest Time Remaining First (STRF) is a CPU scheduling algorithm used in operating systems. In STRF, the operating system selects the process with the smallest remaining burst time (time required to complete its execution) to execute next. • This ensures that the process with the least amount of work remaining is given priority. • STRF aims to minimize the average waiting time and turnaround time for processes, making it an efficient scheduling algorithm for certain scenarios, particularly when dealing with short tasks. • It is a preemptive variant of Shortest Job Next (SJN) scheduling. • Mode -> preemptive • Criteria -> Burst time(B.T)
  • 4. Numericals • Q1). Consider a uniprocessor system, where three processes (Process ID 1, 2, 3 respectively) are there. Arrival time of the three processes are last 3 digits of your registration number (i.e. if your registration number is 201300100110019, arrival time of P1=0, P2=1, P3=9). Burst time of process 1 is the addition of date (dd, i.e. if 21/07/2003 is Date of Birth, then it is 2+1 = 3), process 2 is addition of month (mm, if July then 0+7, i.e. 7), and process 3 is addition of last two digit of the year (yy, if 2003 then 0+3, i.e. 3, if it is 2000 then take first 2 digit). Assume that CPU is using Shortest remaining time first algorithm. i. Calculate Waiting time of each of the process ii. Calculate turnaround time of each of the process. iii. Calculate the percentage of time CPU remains idle. Sol- • Priority:- Shortest Remaining Time First (SRTF) • To Calculate:- 1) Waiting time of each process. 2) Turn around time of each of the process. 3) Percentage of time CPU remains idle. • Registration no. 211300100110097 • Date of Birth- 02/03/2003
  • 5. Processors Arrival Burst P1 0 2 P2 9 3 P3 7 3 PROCESS ID ARRIVAL TIME (AT) BURST TIME (BT) COMPLETION TIME (CT) Turn Around Time (CT-AT) WAITING TIME (TAT-BT) P1 0 2 2 2 0 P2 9 3 13 4 1 P3 7 3 10 3 0 P1 --- P3 P2 0 2 7 10 13 GANTT CHART:-
  • 6. i) Calculated Waiting time of each of the process:- P1=0 P2=1 P3=0 ii) Calculated Turn-around Time of each of the process:- P1=2 P2=4 P3=3 iii) Calculate the percentage of time CPU remains idle:- (Total idle time of CPU/ Total time take for competition of whole process)*100 = (5/13)*100 = 38.46 %
  • 7. FCFS • First Come First Serve (FCFS) is a non-preemptive CPU scheduling algorithm used in operating systems. • In FCFS, processes are executed in the order they arrive in the ready queue . • The process that arrives first is the first to be allocated the CPU, and it continues running until it completes its execution or enters a waiting state. Only when the first process finishes, the next process in the queue is executed, and this process continues until all processes are completed. • FCFS operates on a first-come, first-served basis, without any consideration of the length of the processes or their priority. • While FCFS is easy to implement and ensures fairness, it may lead to long average waiting times, especially if longer processes arrive first and block shorter ones from executing. • Criteria:- Arrival Time(A.T) • Mode:-Non-preemptive • FCFS is not the most efficient scheduling algorithm and may not be suitable for scenarios with varying process execution times.
  • 8. Q2) Consider a uniprocessor system, where there exist three processes (Process ID 1, 2, 3 respectively). CPU assigns priority of the processes based on highest waiting time of the processes present at that time after every 2-unit time. In any process terminates before the interval time then the default situation will be FCFS scheduling. Each of the process will arrive based on the last 3 digits of your university roll number. (If Roll No. is 13000118137, arrival time of P0 =1, P1=3, P2=7). CPU Burst time will be first three digits of your mobile number (i.e. if your mobile number is 8756540439, CPU burst time of P1=8, P2=7, P3=5, if any number is 0, then take next non zero value from your mobile number like 7000312867, CPU burst time of P1=7, P2=3, P3=1). i. Calculate Average Waiting Time. ii. Calculate Average Turnaround Time. iii. Calculate the percentage of time CPU remains idle Sol- Priority:- Highest waiting time after every 2 unit of time interval FCFS(Default: If any process terminates before the interval ) To Calculate:- i. Average Waiting Time ii. Average turn around Time iii. Percentage of time CPU remains idle University roll number : 13000121089 Mobile number : 7003072392
  • 9. Process Arrival Time Burst Time P1 0 7 P2 8 3 P3 9 7 PROCESS ID ARRIVAL TIME (AT) BURST TIME (BT) COMPLETION TIME (CT) Turn Around Time (CT-AT) WAITING TIME (TAT-BT) P1 0 7 7 7 0 P2 8 3 13 5 2 P3 9 7 18 9 2 P1 P1 P1 P1 ----- P2 P3 P2 P3 0 2 4 6 7 8 10 12 13 18
  • 10. i) Calculate Average Waiting Time: (WT of P1 + WT of P2 + WT of P3 )/3 = (0 + 2 + 2)/3 = 4/3 = 1.33 % ii) Calculate Average Turnaround Time : (TAT of P1 + TAT of P2 + TAT of P3)/3 = (7 + 5 + 9)/3 = 21/3 = 7 % iii) Calculate the percentage of time CPU remains idle : (Total idle time of CPU/ Total time take for competition of whole process)*100 = 1/18 * 100 = 5.55 %
  • 11. Conclusion Scheduling algorithms tell the CPU which will be the next process to have CPU time. The main goal of scheduling algorithms in OS is to Maximize Throughput. Scheduling algorithms can be preemptive and non-preemptive.