SlideShare une entreprise Scribd logo
1  sur  37
Process Scheduling/
CPU Scheduling
Process Scheduling
• The act of determining which process in the ready state should be moved
to the running state is known as Process Scheduling.
• The prime aim of the process scheduling system is to keep the CPU busy all
the time and to deliver minimum response time for all programs.
• 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 resource like I/O etc, thereby making full use of CPU.
• The aim of CPU scheduling is to make the system efficient, fast and fair.
• Process scheduling is an essential part of a Multiprogramming operating
systems. Such operating systems allow more than one process to be loaded
into the executable memory at a time and the loaded process shares the
CPU using time multiplexing.
• For achieving this, the scheduler must apply appropriate rules for swapping
processes IN and OUT of CPU.
Process Scheduling Queues
• The OS maintains all PCBs in Process Scheduling Queues.
• The OS maintains a separate queue for each of the process states and PCBs of
all processes in the same execution state are placed in the same queue.
• When the state of a process is changed, its PCB is unlinked from its current
queue and moved to its new state queue.
• The Operating System maintains the following important process scheduling
queues:
oAll processes when enters into the system are stored in the job queue.
oProcesses in the Ready state are placed in the ready queue. This queue keeps a
set of all processes residing in main memory, ready and waiting to execute. A
new process is always put in this queue.
oProcesses waiting for a device to become available are placed in device queues.
There are unique device queues for each I/O device available.
Process Scheduling Queues
Two-State Process Model
• Two-state process model refers to running and non-running states.
Schedulers
• Schedulers are special system software which handle process scheduling in
various ways.
• Their main task is to select the jobs to be submitted into the system and to decide
which process to run.
• Schedulers fell into one of the two general categories :
• Non pre-emptive scheduling. When the currently executing process gives up the
CPU voluntarily.
• Pre-emptive scheduling. When the operating system decides to favor another
process, pre-empting the currently executing process.
• Schedulers are of three types:
o Long-Term Scheduler
o Short-Term Scheduler
o Medium-Term Scheduler
Long-Term Scheduler
• It is also called a job scheduler.
• A long-term scheduler determines which programs are admitted to the
system for processing. It selects processes from the queue and loads them
into memory for execution.
• Process loads into the memory for CPU scheduling.
• The primary objective of the job scheduler is to provide a balanced mix of
jobs, such as I/O bound and processor bound.
• It also controls the degree of multiprogramming. If the degree of
multiprogramming is stable, then the average rate of process creation must
be equal to the average departure rate of processes leaving the system.
• On some systems, the long-term scheduler may not be available or minimal.
Time-sharing operating systems have no long term scheduler.
• When a process changes the state from new to ready, then there is use of
long-term scheduler.
Short Term Scheduler
• It is also called as CPU scheduler and runs very frequently.
• Its main objective is to increase system performance in accordance
with the chosen set of criteria and increase process execution rate.
• It is the change of ready state to running state of the process.
• CPU scheduler selects a process among the processes that are ready
to execute and allocates CPU to one of them.
• Short-term schedulers, also known as dispatchers, make the decision
of which process to execute next.
• Short-term schedulers are faster than long-term schedulers.
Medium Term Scheduler
• Medium-term scheduling is a part of swapping.
• It removes the processes from the memory. It reduces the degree of
multiprogramming.
• The medium-term scheduler is in charge of handling the swapped out-
processes.
• A running process may become suspended if it makes an I/O request.
• A suspended processes cannot make any progress towards completion.
• In this condition, to remove the process from memory and make space for
other processes, the suspended process is moved to the secondary storage.
• This process is called swapping, and the process is said to be swapped out or
rolled out.
• Swapping may be necessary to improve the process mix.
Context Switch
• A context switch is the mechanism to store and restore the state or context of
a CPU in Process Control block so that a process execution can be resumed
from the same point at a later time.
• Using this technique, a context switcher enables multiple processes to share a
single CPU.
• Context switching is an essential part of a multitasking operating system
features.
• When the scheduler switches the CPU from executing one process to execute
another, the state from the current running process is stored into the process
control block.
• After this, the state for the process to run next is loaded from its own PCB and
used to set the PC, registers, etc.
• At that point, the second process can start executing.
Context switching diagram
Scheduling Algorithms
• A Process Scheduler schedules different processes to be assigned to
the CPU based on particular scheduling algorithms.
First-Come, First-Served (FCFS) Scheduling
Shortest-Job-Next (SJN) Scheduling
Priority Scheduling
Shortest Remaining Time
Round Robin(RR) Scheduling
Multiple-Level Queues Scheduling
Multilevel Feedback Queue Scheduling
Scheduling Criteria
• There are many different criterias to check when considering the "best"
scheduling algorithm :
CPU utilization -To make out the best use of CPU and not to waste any
CPU cycle, CPU would be working most of the time(Ideally 100% of the
time). Considering a real system, CPU usage should range from 40%
(lightly loaded) to 90% (heavily loaded.)
Throughput - It is the total number of processes completed per unit time
or rather say total amount of work done in a unit of time. This may range
from 10/second to 1/hour depending on the specific processes.
Turnaround time - It is the amount of time taken to execute a particular
process, i.e. The interval from time of submission of the process to the
time of completion of the process(Wall clock time).
• Waiting time - The sum of the periods spent waiting in the ready queue
amount of time a process has been waiting in the ready queue to
acquire get control on the CPU.
• Load average - It is the average number of processes residing in the
ready queue waiting for their turn to get into the CPU.
• Response time - Amount of time it takes from when a request was
submitted until the first response is produced. Remember, it is the time
till the first response and not the completion of process execution(final
response).
• In general CPU utilization and Throughput are maximized and other
factors are reduced for proper optimization.
• The Algorithms
First Come, First Served (FCFS)
• Jobs are executed on first come, first served basis.
• It is a non-preemptive scheduling algorithm.
• Easy to understand and implement.
• Its implementation is based on FIFO queue.
• Poor in performance, as average wait time is high.
Round Robin Scheduling
• Round Robin is a 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.
Shortest Job Next (SJN)
• This is also known as shortest job first, or SJF.
• This is a non-preemptive scheduling algorithm.
• Best approach to minimize waiting time.
• Easy to implement in Batch systems where required CPU time is known in
advance.
• Impossible to implement in interactive systems where the required CPU
time is not known.
• The processer should know in advance how much time a process will take.
Shortest Remaining Time
• Shortest remaining time (SRT) is the preemptive version of the SJN
algorithm.
• The processor is allocated to the job closest to completion but it can
be preempted by a newer ready job with shorter time to completion.
• Impossible to implement in interactive systems where required CPU
time is not known.
• It is often used in batch environments where short jobs need to be
given preference.
Priority Based Scheduling Algorithm
• Priority is assigned for each process.
• Process with highest priority is executed first and so on.
• Processes with same priority are executed in FCFS manner.
• Priority can be decided based on memory requirements, time
requirements or any other resource requirement.
Multilevel Queue Scheduling
• Multiple-level queues are not an independent scheduling algorithm.
• They make use of other existing algorithms to group and schedule
jobs with common characteristics.
 Multiple queues are maintained for processes with common
characteristics.
 Each queue can have its own scheduling algorithms.
 Priorities are assigned to each queue.
• For example, CPU-bound jobs can be scheduled in one queue and all
I/O-bound jobs in another queue.
• The Process Scheduler then alternately selects jobs from each.
• NB: under this algorithm jobs cannot switch from queue to queue -
Once they are assigned a queue, that is their queue until they finish.
Multilevel feedback queue scheduling
• Multilevel feedback queue scheduling is similar to the ordinary multilevel
queue scheduling described above, except jobs may be moved from one
queue to another for a variety of reasons:
o If the characteristics of a job change between CPU-intensive and I/O intensive, then it
may be appropriate to switch a job from one queue to another.
o Aging can also be incorporated, so that a job that has waited for a long time can get
bumped up into a higher priority queue for a while.
• Multilevel feedback queue scheduling is the most flexible, because it can be
tuned for any situation. But it is also the most complex to implement because
of all the adjustable parameters. Some of the parameters which define one of
these systems include:
o The number of queues.
o The scheduling algorithm for each queue.
o The methods used to upgrade or demote processes from one queue to another. ( Which
may be different. )
o The method used to determine which queue a process enters initially.
The algorithm

Contenu connexe

Tendances (20)

Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round RobinComparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
Comparison Analysis of CPU Scheduling : FCFS, SJF and Round Robin
 
Process scheduling linux
Process scheduling linuxProcess scheduling linux
Process scheduling linux
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
RTOS - Real Time Operating Systems
RTOS - Real Time Operating SystemsRTOS - Real Time Operating Systems
RTOS - Real Time Operating Systems
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
scheduling
schedulingscheduling
scheduling
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
 
Memory management
Memory managementMemory management
Memory management
 
Chapter 3 - Processes
Chapter 3 - ProcessesChapter 3 - Processes
Chapter 3 - Processes
 
Operating System Scheduling Algorithms
Operating System Scheduling AlgorithmsOperating System Scheduling Algorithms
Operating System Scheduling Algorithms
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Priority Scheduling
Priority Scheduling  Priority Scheduling
Priority Scheduling
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
 
Operating Systems - memory management
Operating Systems - memory managementOperating Systems - memory management
Operating Systems - memory management
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 

Similaire à Lecture 4 process cpu scheduling

operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdfAliyanAbbas1
 
Operating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingOperating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingVaibhav Khanna
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptxDivyaKS18
 
CPU Scheduling Criteria CPU Scheduling Criteria (1).pptx
CPU Scheduling Criteria CPU Scheduling Criteria (1).pptxCPU Scheduling Criteria CPU Scheduling Criteria (1).pptx
CPU Scheduling Criteria CPU Scheduling Criteria (1).pptxTSha7
 
Unit 2_OS process management
Unit 2_OS process management Unit 2_OS process management
Unit 2_OS process management JayeshGadhave1
 
Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Maitree Patel
 
Lecture 4 - Process Scheduling (1).pptx
Lecture 4 - Process Scheduling (1).pptxLecture 4 - Process Scheduling (1).pptx
Lecture 4 - Process Scheduling (1).pptxAmanuelmergia
 
Schudling os presentaion
Schudling os presentaionSchudling os presentaion
Schudling os presentaioninayat khan
 
Lecture 4 - Process Scheduling.pptx
Lecture 4 - Process Scheduling.pptxLecture 4 - Process Scheduling.pptx
Lecture 4 - Process Scheduling.pptxAmanuelmergia
 
LM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesLM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesmanideepakc
 
CPU Scheduling.pptx
CPU Scheduling.pptxCPU Scheduling.pptx
CPU Scheduling.pptxyashu23
 
Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...ApurvaLaddha
 
Multi-Threading.pptx
Multi-Threading.pptxMulti-Threading.pptx
Multi-Threading.pptxCHANDRUG31
 
L6 CPU Scheduling.pptx
L6 CPU Scheduling.pptxL6 CPU Scheduling.pptx
L6 CPU Scheduling.pptxSeniorGaming
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxansariparveen06
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .nathansel1
 

Similaire à Lecture 4 process cpu scheduling (20)

operating system (1).pdf
operating system (1).pdfoperating system (1).pdf
operating system (1).pdf
 
Operating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingOperating system 28 fundamental of scheduling
Operating system 28 fundamental of scheduling
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
CPU Scheduling Criteria CPU Scheduling Criteria (1).pptx
CPU Scheduling Criteria CPU Scheduling Criteria (1).pptxCPU Scheduling Criteria CPU Scheduling Criteria (1).pptx
CPU Scheduling Criteria CPU Scheduling Criteria (1).pptx
 
Unit 2_OS process management
Unit 2_OS process management Unit 2_OS process management
Unit 2_OS process management
 
Scheduling Definition, objectives and types
Scheduling Definition, objectives and types Scheduling Definition, objectives and types
Scheduling Definition, objectives and types
 
Lecture 4 - Process Scheduling (1).pptx
Lecture 4 - Process Scheduling (1).pptxLecture 4 - Process Scheduling (1).pptx
Lecture 4 - Process Scheduling (1).pptx
 
Schudling os presentaion
Schudling os presentaionSchudling os presentaion
Schudling os presentaion
 
Lecture 4 - Process Scheduling.pptx
Lecture 4 - Process Scheduling.pptxLecture 4 - Process Scheduling.pptx
Lecture 4 - Process Scheduling.pptx
 
LM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processesLM10,11,12 - CPU SCHEDULING algorithms and its processes
LM10,11,12 - CPU SCHEDULING algorithms and its processes
 
CPU Scheduling.pptx
CPU Scheduling.pptxCPU Scheduling.pptx
CPU Scheduling.pptx
 
ch_scheduling (1).ppt
ch_scheduling (1).pptch_scheduling (1).ppt
ch_scheduling (1).ppt
 
CPU Scheduling Part-I.pdf
CPU Scheduling Part-I.pdfCPU Scheduling Part-I.pdf
CPU Scheduling Part-I.pdf
 
Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...
 
Multi-Threading.pptx
Multi-Threading.pptxMulti-Threading.pptx
Multi-Threading.pptx
 
L6 CPU Scheduling.pptx
L6 CPU Scheduling.pptxL6 CPU Scheduling.pptx
L6 CPU Scheduling.pptx
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
 
Operating System.pptx
Operating System.pptxOperating System.pptx
Operating System.pptx
 
In computing, scheduling is the action .
In computing, scheduling is the action .In computing, scheduling is the action .
In computing, scheduling is the action .
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 

Dernier

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 

Dernier (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 

Lecture 4 process cpu scheduling

  • 2. Process Scheduling • The act of determining which process in the ready state should be moved to the running state is known as Process Scheduling. • The prime aim of the process scheduling system is to keep the CPU busy all the time and to deliver minimum response time for all programs. • 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 resource like I/O etc, thereby making full use of CPU. • The aim of CPU scheduling is to make the system efficient, fast and fair. • Process scheduling is an essential part of a Multiprogramming operating systems. Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing. • For achieving this, the scheduler must apply appropriate rules for swapping processes IN and OUT of CPU.
  • 3. Process Scheduling Queues • The OS maintains all PCBs in Process Scheduling Queues. • The OS maintains a separate queue for each of the process states and PCBs of all processes in the same execution state are placed in the same queue. • When the state of a process is changed, its PCB is unlinked from its current queue and moved to its new state queue. • The Operating System maintains the following important process scheduling queues: oAll processes when enters into the system are stored in the job queue. oProcesses in the Ready state are placed in the ready queue. This queue keeps a set of all processes residing in main memory, ready and waiting to execute. A new process is always put in this queue. oProcesses waiting for a device to become available are placed in device queues. There are unique device queues for each I/O device available.
  • 5. Two-State Process Model • Two-state process model refers to running and non-running states.
  • 6. Schedulers • Schedulers are special system software which handle process scheduling in various ways. • Their main task is to select the jobs to be submitted into the system and to decide which process to run. • Schedulers fell into one of the two general categories : • Non pre-emptive scheduling. When the currently executing process gives up the CPU voluntarily. • Pre-emptive scheduling. When the operating system decides to favor another process, pre-empting the currently executing process. • Schedulers are of three types: o Long-Term Scheduler o Short-Term Scheduler o Medium-Term Scheduler
  • 7. Long-Term Scheduler • It is also called a job scheduler. • A long-term scheduler determines which programs are admitted to the system for processing. It selects processes from the queue and loads them into memory for execution. • Process loads into the memory for CPU scheduling. • The primary objective of the job scheduler is to provide a balanced mix of jobs, such as I/O bound and processor bound. • It also controls the degree of multiprogramming. If the degree of multiprogramming is stable, then the average rate of process creation must be equal to the average departure rate of processes leaving the system. • On some systems, the long-term scheduler may not be available or minimal. Time-sharing operating systems have no long term scheduler. • When a process changes the state from new to ready, then there is use of long-term scheduler.
  • 8. Short Term Scheduler • It is also called as CPU scheduler and runs very frequently. • Its main objective is to increase system performance in accordance with the chosen set of criteria and increase process execution rate. • It is the change of ready state to running state of the process. • CPU scheduler selects a process among the processes that are ready to execute and allocates CPU to one of them. • Short-term schedulers, also known as dispatchers, make the decision of which process to execute next. • Short-term schedulers are faster than long-term schedulers.
  • 9. Medium Term Scheduler • Medium-term scheduling is a part of swapping. • It removes the processes from the memory. It reduces the degree of multiprogramming. • The medium-term scheduler is in charge of handling the swapped out- processes. • A running process may become suspended if it makes an I/O request. • A suspended processes cannot make any progress towards completion. • In this condition, to remove the process from memory and make space for other processes, the suspended process is moved to the secondary storage. • This process is called swapping, and the process is said to be swapped out or rolled out. • Swapping may be necessary to improve the process mix.
  • 10.
  • 11. Context Switch • A context switch is the mechanism to store and restore the state or context of a CPU in Process Control block so that a process execution can be resumed from the same point at a later time. • Using this technique, a context switcher enables multiple processes to share a single CPU. • Context switching is an essential part of a multitasking operating system features. • When the scheduler switches the CPU from executing one process to execute another, the state from the current running process is stored into the process control block. • After this, the state for the process to run next is loaded from its own PCB and used to set the PC, registers, etc. • At that point, the second process can start executing.
  • 13. Scheduling Algorithms • A Process Scheduler schedules different processes to be assigned to the CPU based on particular scheduling algorithms. First-Come, First-Served (FCFS) Scheduling Shortest-Job-Next (SJN) Scheduling Priority Scheduling Shortest Remaining Time Round Robin(RR) Scheduling Multiple-Level Queues Scheduling Multilevel Feedback Queue Scheduling
  • 14. Scheduling Criteria • There are many different criterias to check when considering the "best" scheduling algorithm : CPU utilization -To make out the best use of CPU and not to waste any CPU cycle, CPU would be working most of the time(Ideally 100% of the time). Considering a real system, CPU usage should range from 40% (lightly loaded) to 90% (heavily loaded.) Throughput - It is the total number of processes completed per unit time or rather say total amount of work done in a unit of time. This may range from 10/second to 1/hour depending on the specific processes. Turnaround time - It is the amount of time taken to execute a particular process, i.e. The interval from time of submission of the process to the time of completion of the process(Wall clock time).
  • 15. • Waiting time - The sum of the periods spent waiting in the ready queue amount of time a process has been waiting in the ready queue to acquire get control on the CPU. • Load average - It is the average number of processes residing in the ready queue waiting for their turn to get into the CPU. • Response time - Amount of time it takes from when a request was submitted until the first response is produced. Remember, it is the time till the first response and not the completion of process execution(final response). • In general CPU utilization and Throughput are maximized and other factors are reduced for proper optimization.
  • 17. First Come, First Served (FCFS) • Jobs are executed on first come, first served basis. • It is a non-preemptive scheduling algorithm. • Easy to understand and implement. • Its implementation is based on FIFO queue. • Poor in performance, as average wait time is high.
  • 18.
  • 19.
  • 20.
  • 21. Round Robin Scheduling • Round Robin is a 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.
  • 22.
  • 23.
  • 24. Shortest Job Next (SJN) • This is also known as shortest job first, or SJF. • This is a non-preemptive scheduling algorithm. • Best approach to minimize waiting time. • Easy to implement in Batch systems where required CPU time is known in advance. • Impossible to implement in interactive systems where the required CPU time is not known. • The processer should know in advance how much time a process will take.
  • 25.
  • 26.
  • 27.
  • 28. Shortest Remaining Time • Shortest remaining time (SRT) is the preemptive version of the SJN algorithm. • The processor is allocated to the job closest to completion but it can be preempted by a newer ready job with shorter time to completion. • Impossible to implement in interactive systems where required CPU time is not known. • It is often used in batch environments where short jobs need to be given preference.
  • 29.
  • 30. Priority Based Scheduling Algorithm • Priority is assigned for each process. • Process with highest priority is executed first and so on. • Processes with same priority are executed in FCFS manner. • Priority can be decided based on memory requirements, time requirements or any other resource requirement.
  • 31.
  • 32.
  • 33.
  • 34. Multilevel Queue Scheduling • Multiple-level queues are not an independent scheduling algorithm. • They make use of other existing algorithms to group and schedule jobs with common characteristics.  Multiple queues are maintained for processes with common characteristics.  Each queue can have its own scheduling algorithms.  Priorities are assigned to each queue. • For example, CPU-bound jobs can be scheduled in one queue and all I/O-bound jobs in another queue. • The Process Scheduler then alternately selects jobs from each. • NB: under this algorithm jobs cannot switch from queue to queue - Once they are assigned a queue, that is their queue until they finish.
  • 35.
  • 36. Multilevel feedback queue scheduling • Multilevel feedback queue scheduling is similar to the ordinary multilevel queue scheduling described above, except jobs may be moved from one queue to another for a variety of reasons: o If the characteristics of a job change between CPU-intensive and I/O intensive, then it may be appropriate to switch a job from one queue to another. o Aging can also be incorporated, so that a job that has waited for a long time can get bumped up into a higher priority queue for a while. • Multilevel feedback queue scheduling is the most flexible, because it can be tuned for any situation. But it is also the most complex to implement because of all the adjustable parameters. Some of the parameters which define one of these systems include: o The number of queues. o The scheduling algorithm for each queue. o The methods used to upgrade or demote processes from one queue to another. ( Which may be different. ) o The method used to determine which queue a process enters initially.