SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Experiment Number: 03
TITLE: CPU Scheduling Algorithms: Shortest Job First (Preemptive) and
Round Robin with different arrival time.
OBJECTIVE:
1. Demonstration of CPU Scheduling algorithm.
2. Implement CPU Scheduling algorithm.
SOFTWARE REQUIREMENTS:
1. LINUX OPERATING SYSTEM LIKE FEDORA/REDHAT/UBUNTU….
2. GNU C Compiler
PROBLEM STATEMENT: Implement the C program for CPU Scheduling
Algorithms: Shortest Job First (Preemptive) and Round Robin with different
arrival time.
THEORY:
Shortest Remaining Time First (SRTF) scheduling
In the Shortest Remaining Time First (SRTF) scheduling algorithm, the
process with the smallest amount of time remaining until completion is
selected to execute. Since the currently executing process is the one with
the shortest amount of time remaining by definition, and since that time
should only reduce as execution progresses, processes will always run until
they complete or a new process is added that requires a smaller amount of
time.
Advantage:
1- Short processes are handled very quickly.
2- The system also requires very little overhead since it only makes a
decision when a process completes or a new process is added.
3- When a new process is added the algorithm only needs to compare the
currently executing process with the new process, ignoring all other
processes currently waiting to execute.
Disadvantage:
1- Like shortest job first, it has the potential for process starvation.
2- Long processes may be held off indefinitely if short processes are
continually added.
How to compute below times in SJF using a program?
1. Completion Time: Time at which process completes its execution.
2. Turn Around Time: Time Difference between completion time and arrival
time. Turn Around Time = Completion Time – Arrival Time
3. Waiting Time(W.T): Time Difference between turn around time and burst
time.
Waiting Time = Turn Around Time – Burst Time
SJF CPU SCHEDULING ALGORITHM :
For SJF scheduling algorithm, read the number of processes/jobs in
the system, their CPU burst times. Arrange all the jobs in order with respect
to their burst times. There may be two jobs in queue with the same
execution time, and then FCFS approach is to be performed. Each process
will be executed according to the length of its burst time. Then calculate the
waiting time and turnaround time of each of the processes accordingly.
ROUND ROBIN CPU SCHEDULING ALGORITHM:
The name of this algorithm comes from the round-robin principle,
where each person gets an equal share of something in turns. It is the
oldest, simplest scheduling algorithm, which is mostly used for multitasking.
In Round-robin scheduling, each ready task runs turn by turn only in a cyclic
queue for a limited time slice. This algorithm also offers starvation free
execution of processes.
For round robin scheduling algorithm, read the number of
processes/jobs in the system, their CPU burst times, and the size of the time
slice. Time slices are assigned to each process in equal portions and in
circular order, handling all processes execution. This allows every process to
get an equal chance. Calculate the waiting time and turnaround time of each
of the processes accordingly.
Characteristics of Round-Robin Scheduling
Here are the important characteristics of Round-Robin Scheduling:
 Round robin is a pre-emptive algorithm
 The CPU is shifted to the next process after fixed interval time, which
is called time quantum/time slice.
 The process that is preempted is added to the end of the queue.
 Round robin is a hybrid model which is clock-driven
 Time slice should be minimum, which is assigned for a specific task
that needs to be processed. However, it may differ OS to OS.
 It is a real time algorithm which responds to the event within a specific
time limit.
 Round robin is one of the oldest, fairest, and easiest algorithm.
 Widely used scheduling method in traditional OS.
ALGORITHM
1. Start
2. Declare the array size
3. Read the number of processes to be inserted
4. Read the burst times of the processes
5. Read the Time Quantum
6. If the burst time of a process is greater than time Quantum then subtract
time quantum form the burst time
Else
Assign the burst time to time quantum.
7. Calculate the average waiting time and turnaround time of the processes.
8. Display the values
9. Stop
Note : Solve one example of each algorithm.
CONCLUSION (At least three points):
1. Understood what is CPU scheduling.
2. Studied concept of Preemptive and non-preemptive scheduling.
3. Studied and implemented CPU scheduling algorithm.
REFERENCES:
1. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne, Operating
System Concepts, John Wiley & Sons ,Inc., 9th Edition

Weitere ähnliche Inhalte

Ähnlich wie exp 3.docx

Process management in os
Process management in osProcess management in os
Process management in osMiong Lazaro
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationAnitaSofiaKeyser
 
An improved round robin cpu scheduling
An improved round robin cpu schedulingAn improved round robin cpu scheduling
An improved round robin cpu schedulingIJCSEA Journal
 
An Improved Round Robin CPU Scheduling Algorithm with Varying Time Quantum
An Improved Round Robin CPU Scheduling Algorithm with Varying Time QuantumAn Improved Round Robin CPU Scheduling Algorithm with Varying Time Quantum
An Improved Round Robin CPU Scheduling Algorithm with Varying Time QuantumIJCSEA Journal
 
AN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUM
AN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUMAN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUM
AN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUMIJCSEA Journal
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptxDivyaKS18
 
Cpu scheduling final
Cpu scheduling finalCpu scheduling final
Cpu scheduling finalmarangburu42
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling gopi7
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptxjamilaltiti1
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - EngineeringYogesh Santhan
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formattingmarangburu42
 
Do2644844490
Do2644844490Do2644844490
Do2644844490IJMER
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
Operating System 5
Operating System 5Operating System 5
Operating System 5tech2click
 

Ähnlich wie exp 3.docx (20)

Process management in os
Process management in osProcess management in os
Process management in os
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
CPU scheduling in Operating System Explanation
CPU scheduling in Operating System ExplanationCPU scheduling in Operating System Explanation
CPU scheduling in Operating System Explanation
 
An improved round robin cpu scheduling
An improved round robin cpu schedulingAn improved round robin cpu scheduling
An improved round robin cpu scheduling
 
Operating system
Operating systemOperating system
Operating system
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
An Improved Round Robin CPU Scheduling Algorithm with Varying Time Quantum
An Improved Round Robin CPU Scheduling Algorithm with Varying Time QuantumAn Improved Round Robin CPU Scheduling Algorithm with Varying Time Quantum
An Improved Round Robin CPU Scheduling Algorithm with Varying Time Quantum
 
AN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUM
AN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUMAN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUM
AN IMPROVED ROUND ROBIN CPU SCHEDULING ALGORITHM WITH VARYING TIME QUANTUM
 
Section05 scheduling
Section05 schedulingSection05 scheduling
Section05 scheduling
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
Cpu scheduling final
Cpu scheduling finalCpu scheduling final
Cpu scheduling final
 
Ch05
Ch05Ch05
Ch05
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling
 
Preemptive process example.pptx
Preemptive process example.pptxPreemptive process example.pptx
Preemptive process example.pptx
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
 
Cpu scheduling pre final formatting
Cpu scheduling pre final formattingCpu scheduling pre final formatting
Cpu scheduling pre final formatting
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Do2644844490
Do2644844490Do2644844490
Do2644844490
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 

Mehr von Ganesh Chavan

Mehr von Ganesh Chavan (8)

rao-vlsi-comm-09 (1).ppt
rao-vlsi-comm-09 (1).pptrao-vlsi-comm-09 (1).ppt
rao-vlsi-comm-09 (1).ppt
 
wap01.ppt
wap01.pptwap01.ppt
wap01.ppt
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
crypto.ppt
crypto.pptcrypto.ppt
crypto.ppt
 
Lecture02 types
Lecture02 typesLecture02 types
Lecture02 types
 
Project00
Project00Project00
Project00
 
Nachos
NachosNachos
Nachos
 
Kernel compilation
Kernel compilationKernel compilation
Kernel compilation
 

Kürzlich hochgeladen

FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming languageSmritiSharma901052
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 

Kürzlich hochgeladen (20)

FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming language
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 

exp 3.docx

  • 1. Experiment Number: 03 TITLE: CPU Scheduling Algorithms: Shortest Job First (Preemptive) and Round Robin with different arrival time. OBJECTIVE: 1. Demonstration of CPU Scheduling algorithm. 2. Implement CPU Scheduling algorithm. SOFTWARE REQUIREMENTS: 1. LINUX OPERATING SYSTEM LIKE FEDORA/REDHAT/UBUNTU…. 2. GNU C Compiler PROBLEM STATEMENT: Implement the C program for CPU Scheduling Algorithms: Shortest Job First (Preemptive) and Round Robin with different arrival time. THEORY: Shortest Remaining Time First (SRTF) scheduling In the Shortest Remaining Time First (SRTF) scheduling algorithm, the process with the smallest amount of time remaining until completion is selected to execute. Since the currently executing process is the one with the shortest amount of time remaining by definition, and since that time should only reduce as execution progresses, processes will always run until they complete or a new process is added that requires a smaller amount of time.
  • 2. Advantage: 1- Short processes are handled very quickly. 2- The system also requires very little overhead since it only makes a decision when a process completes or a new process is added. 3- When a new process is added the algorithm only needs to compare the currently executing process with the new process, ignoring all other processes currently waiting to execute. Disadvantage: 1- Like shortest job first, it has the potential for process starvation. 2- Long processes may be held off indefinitely if short processes are continually added. How to compute below times in SJF using a program? 1. Completion Time: Time at which process completes its execution. 2. Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time 3. Waiting Time(W.T): Time Difference between turn around time and burst time. Waiting Time = Turn Around Time – Burst Time SJF CPU SCHEDULING ALGORITHM : For SJF scheduling algorithm, read the number of processes/jobs in the system, their CPU burst times. Arrange all the jobs in order with respect to their burst times. There may be two jobs in queue with the same execution time, and then FCFS approach is to be performed. Each process will be executed according to the length of its burst time. Then calculate the waiting time and turnaround time of each of the processes accordingly. ROUND ROBIN CPU SCHEDULING ALGORITHM: The name of this algorithm comes from the round-robin principle, where each person gets an equal share of something in turns. It is the oldest, simplest scheduling algorithm, which is mostly used for multitasking. In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue for a limited time slice. This algorithm also offers starvation free execution of processes.
  • 3. For round robin scheduling algorithm, read the number of processes/jobs in the system, their CPU burst times, and the size of the time slice. Time slices are assigned to each process in equal portions and in circular order, handling all processes execution. This allows every process to get an equal chance. Calculate the waiting time and turnaround time of each of the processes accordingly. Characteristics of Round-Robin Scheduling Here are the important characteristics of Round-Robin Scheduling:  Round robin is a pre-emptive algorithm  The CPU is shifted to the next process after fixed interval time, which is called time quantum/time slice.  The process that is preempted is added to the end of the queue.  Round robin is a hybrid model which is clock-driven  Time slice should be minimum, which is assigned for a specific task that needs to be processed. However, it may differ OS to OS.  It is a real time algorithm which responds to the event within a specific time limit.  Round robin is one of the oldest, fairest, and easiest algorithm.  Widely used scheduling method in traditional OS. ALGORITHM 1. Start 2. Declare the array size 3. Read the number of processes to be inserted 4. Read the burst times of the processes 5. Read the Time Quantum 6. If the burst time of a process is greater than time Quantum then subtract time quantum form the burst time Else Assign the burst time to time quantum. 7. Calculate the average waiting time and turnaround time of the processes. 8. Display the values 9. Stop Note : Solve one example of each algorithm. CONCLUSION (At least three points):
  • 4. 1. Understood what is CPU scheduling. 2. Studied concept of Preemptive and non-preemptive scheduling. 3. Studied and implemented CPU scheduling algorithm. REFERENCES: 1. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne, Operating System Concepts, John Wiley & Sons ,Inc., 9th Edition