SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Downloaden Sie, um offline zu lesen
Operating system
Cpu scheduling
Cpu scheduling objectives:
❖ Introduce CPU scheduling, which is the basis for multiprogrammed
operating systems.
❖ Describe various cpu-scheduling algorithms.
❖ Discuss evaluation criteria for selecting a cpu-scheduling algorithm
for a particular system.
Introduction
❖ CPU scheduling is the task performed by CPU that decidesthe way
processedwould be executed.CPU resources are allocated to a process for
only a limited period of time and then those resources are taken back. A
running process could be interrupted to execute a higher priority process.
❖ 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 systemefficient, fast and fair.
Cpu scheduling basis for multiprogrammed operating
system:
CPU scheduling is the basis of multiprogrammed operating systems. By
switching the CPU among processes, the operating system can make the
computer more productive. In this chapter, we introduce basic CPU-scheduling
concepts and present several CPU-scheduling algorithms.
2 Types of cpu scheduling:
• Preemptive
• Non preemptive
Preemptive scheduling:
Preemptive scheduling is when a processtransitions from a running state to
a ready state or from a waiting state to a ready state.
Most common and complex.
Example:
• when a higher priority task wants the CPU.
• SRTF
• Priority(preemptive)
• RR
Scheduling overhead:
• Additional operations that take small amount of time
• RR
• SRTF
• Priority (preemptive)
• Multi-level feedback
• Hybrid scheduling scheme
Algorithms based on preemptive scheduling are: RoundRobin (RR),Shortest RemainingTime First (SRTF), Priority
(preemptive version), etc.
Non preemptive scheduling:
Non-preemptive Scheduling is used when a process terminates,or a process
switches from running to the waiting state.In this scheduling, once the
resources (CPU cycles) are allocated to a process. In the case of non-
preemptive scheduling does not interrupt a process running CPU in the
middle of the execution. Instead, it waits till the process completes its CPU
burst time, and then it can allocate the CPU to another process.
Example:
Non-preemptive Scheduling is rigid. ShortestRemaining Time First, Round
Robin, First Come First Serve, Shortest Job First(non-preemptive), Priority
Scheduling, etc.
Algorithms based on non-preemptive scheduling are: Shortest Job First (SJF basicallynon
preemptive) and Priority (non preemptive version), etc.
How is scheduler invoked:
➢ Voluntarily
• Process block due to I/o
• Calls scheduler
• E.g. FCFS, SJF
➢ Involuntarily
• Preemption done by algorithm or timer
• Kernal calls scheduler to take necessary action
• E.g. SRTF ,RR
Scheduler policy:
➢ Ideal
• Selectable
• Changeable
➢ Practical
• Built-in os
• Different versions may have different scheduling scheme
➢ Additional
• Resource manager _ deadlock manager
Control over scheduling:
➢ Interval timer
• Time quantum _ static or dynamic
➢ Policy based
• Interactive
• Batch system
• Real time application
How policies are implemented:
➢ Mechanism behind working
➢ Requirement _ factors
• Cpu utilization
• Waiting time
• Turnaround time
➢ Controls
• Fair share among jobs
• Favor given to different jobs
• priorities
Cpu scheduling algorithms:
A Process Scheduler schedules different processes to be assigned to
the CPU based on particular scheduling algorithms. There are six
popular process scheduling algorithms which we are going to discuss in
this chapter −
Scheduling variables:
• Set of processes
• Set of states
• Service time set
• Waiting time
• Turnaround time
• Batch throughput
• Time sharing time slice(if any)
How to optimize scheduling algorithm?
➢ Scheduling function vs. Decision mode
➢ Define criteria to optimize
• Scheduling criteria
➢ Use set of methods
• Restrict no. of processes
• Pre-determine service time
• Compute run-time of all schedulers and decide the best
Types of cpu scheduling algorithm:
➢First-Come, First-Served (FCFS) Scheduling
➢Shortest-Job-Next (SJN) Scheduling
➢Priority Scheduling
➢Shortest Remaining Time
➢Round Robin(RR) Scheduling
➢Multiple-Level Queues Scheduling
First come first serve(FCFS)
• Jobs are executed on first come, first serve basis.
• It is a non-preemptive, pre-emptive scheduling algorithm.
• Easy to understand and implement.
• Its implementation is based on FIFO queue.
• Poor in performance as average wait time is high.
Waiting time of each process is as follows −
Proces
s
Wait Time : Service Time - ArrivalTime
P0 0 : 0 - 0
P1 4 : 5 - 1
P2 8 - 2 = 6
P3 16 - 3 = 13
Average Wait Time: (0+4+6+13) / 4 = 5.75
Shortest job Next(SJN)
• This is also known as shortest job first, or SJF
• This is a non-preemptive, pre-emptive 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 required CPU time is
not known.
• The processer should know in advance how much time process will take.
Waiting time of each process is as follows −
Proces
s
Waiting Time
P0 0 - 0 = 0
P1 5 - 1 = 4
P2 14 - 2 = 12
P3 8 - 3 = 5
Average Wait Time: (0 + 4 + 12 + 5)/4 = 21 / 4 = 5.25
Priority Based Scheduling
• Priority scheduling is a non-preemptive 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.
• Processes with same priority are executed on first come first served
basis.
• Priority can be decided based on memory requirements, time
requirements or any other resource requirement.
Waiting time of each process is as follows −
Process Waiting Time
P0 0 - 0 = 0
P1 11 - 1 = 10
P2 14 - 2 = 12
P3 5 - 3 = 2
Average Wait Time: (0 + 10 + 12 + 2)/4 = 24 / 4 = 6
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 give
preference.
More and short term scheduler:
➢ Works in co-operation with dispatcher
➢ Frequently occurs and decides which process runs next
➢ Uses:
• Clock interrupts
• I/o interrupts
• System calls
• Traps or signals
• Any blocking event
➢ Uses some algorithm and aims at scheduling criteria
Round Robin(RR)Scheduling:
• 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.
Wait time of each process is as follows −
Process Wait Time : Service Time - ArrivalTime
P0 (0 - 0) + (12 - 3) = 9
P1 (3 - 1) = 2
P2 (6 - 2) + (14 - 9) + (20 - 17) = 12
P3 (9 - 3) + (17 - 12) = 11
Average Wait Time: (9+2+12+11) / 4 = 8.5
Multiple-Level Queues 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 queue and assigns them to
the CPU based on the algorithm assigned to the
queue.
Short term scheduling on multi-processor
systems:
➢ Load sharing
• Global queue for processes
• Central data structure that is properly synchronized
• Even distribution among cpus
➢ Gang scheduling
• 1:1 threads selected to be executed on a particular set of cpus
➢ Dedicated processes assignment
• Assignment threads to specific processes
➢ Dynamic scheduling
• No . of threads per application are altered by scheduler
Multi-queue scheduling:
➢ Ready queue is partitioned into multiple queue
• Real time vs. Batch processes
➢ Each queue has different scheduling algo
• Set of algorithms
➢ Scheduling among queues
• Fixed priority based
• Time slice based
Multiprocessor thread scheduling:
➢ Thread run on any cpu unless specified
➢ Affinity
▪ Soft
• Scheduler tries to keep thread on the same cpu
▪ Hard
• Threads are always bound to specific cpu
Thread scheduling states:
What is dispatching:
➢Dispatcher is built – in os and works with short term scheduler
▪ Tells cpu about the newly selected process for execution
➢Various responsibilities:
▪ Determine the process at head of ready queue
▪ Preemption of current process – various reasons
▪ Context switch
• Save stateof some process
• Load stateof some process
➢Dispatchlatency
▪ Time taken by dispatcher to stop one and start another
Mcqs OF CPU Scheduling
1. Round robin scheduling falls under the category of ____________
a) Non-preemptive scheduling
b) Preemptive scheduling
c) All of the mentioned
d) None of the mentioned
2. With round robin scheduling algorithm in a time shared system ____________
a) using very large time slices converts it intoFirst come First served scheduling
algorithm
b) using very small time slices converts it intoFirst come First served scheduling
algorithm
c) using extremely small time slices increases performance
d) using very small time slices converts it intoShortest Job First algorithm
3. The portion of the process scheduler in an operatingsystem that dispatches
processes is concerned with ____________
a) assigning ready processes to CPU
b) assigning ready processes to waitingqueue
c) assigning running processes to blocked queue
d) all of the mentioned
4. Complex scheduling algorithms ____________
a) are very appropriate for very large computers
b) use minimal resources
c) use many resources
d) all of the mentioned
5. What is FIFO algorithm?
a) first executes the job that came in last in the queue
b) first executes the job that came in first in the queue
c) first executes the job that needs minimal processor
d) first executes the job that has maximum processor needs
6. The strategy of making processes that are logicallyrunnableto be temporarilysuspended is called
____________
a) Non preemptive scheduling
b) Preemptive scheduling
c) Shortest job first
d) First come First served
7. What is Scheduling?
a) allowing a job to use the processor
b) making proper use of processor
c) all of the mentioned
d) none of the mentioned
8. There are 10 different processes running on a workstation.Idle processes are waiting for an
input event in the input queue. Busy processes are scheduled with the Round-Robin timesharing
method. Which out of the following quantum times is the best value for small response times, if
the processes have a short runtime, e.g. less than 10ms?
a) tQ = 15ms
b) tQ = 40ms
c) tQ = 45ms
d) tQ = 50ms
9. Orders are processed in the sequence they arrive if _______ rule sequences the jobs.
a) earliest due date
b) slack time remaining
c) first come, first served
d) critical ratio
10. Which of the following algorithms tends to minimize the process flow time?
a) First come First served
b) Shortest Job First
c) Earliest Deadline First
d) Longest Job First
11. Under multiprogramming, turnaroundtime for short jobs is usually ________ and that for long jobs is slightly
___________
a) Lengthened; Shortened
b) Shortened; Lengthened
c) Shortened; Shortened
d) Shortened; Unchanged
1. which of the followingcan not be scheduled by the kernel?
A. process
B. user-level thread
C. kernel-level thread
D. none of the mentioned
•What is the base of CPU scheduling?​
•What is the purpose of CPU scheduling?​
•Which is the fastest CPU scheduling algorithm?​
•Why do we need scheduling?​
•What type of scheduling is FIFO?​
•What is shortest job first scheduling?​
•What are the 2 different types of scheduling queues?​
•Is FIFO and FCFS same?​
•Which is better SJF or RR?​
•What is deadlock in OS?​
Short questions:
Cpu scheduling

Weitere ähnliche Inhalte

Ähnlich wie operating system (1).pdf

Ähnlich wie operating system (1).pdf (20)

chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
 
L6 CPU Scheduling.pptx
L6 CPU Scheduling.pptxL6 CPU Scheduling.pptx
L6 CPU Scheduling.pptx
 
Ch6 cpu scheduling
Ch6   cpu schedulingCh6   cpu scheduling
Ch6 cpu scheduling
 
Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Section05 scheduling
Section05 schedulingSection05 scheduling
Section05 scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
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
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 
scheduling Uni processor Long-term .ppt
scheduling  Uni processor Long-term .pptscheduling  Uni processor Long-term .ppt
scheduling Uni processor Long-term .ppt
 
Operating system
Operating systemOperating system
Operating system
 
Operating system 28 fundamental of scheduling
Operating system 28 fundamental of schedulingOperating system 28 fundamental of scheduling
Operating system 28 fundamental of scheduling
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
programming .pptx
programming .pptxprogramming .pptx
programming .pptx
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
 
CPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdfCPU Scheduling Part-III.pdf
CPU Scheduling Part-III.pdf
 
CPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptxCPU Scheduling Lecture 5 - 6.pptx
CPU Scheduling Lecture 5 - 6.pptx
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
Operating system 30 preemptive scheduling
Operating system 30 preemptive schedulingOperating system 30 preemptive scheduling
Operating system 30 preemptive scheduling
 
Scheduling
SchedulingScheduling
Scheduling
 

Kürzlich hochgeladen

Jual Obat Aborsi Samarinda ( No.1 ) 088980685493 Obat Penggugur Kandungan Cy...
Jual Obat Aborsi Samarinda (  No.1 ) 088980685493 Obat Penggugur Kandungan Cy...Jual Obat Aborsi Samarinda (  No.1 ) 088980685493 Obat Penggugur Kandungan Cy...
Jual Obat Aborsi Samarinda ( No.1 ) 088980685493 Obat Penggugur Kandungan Cy...
Obat Aborsi 088980685493 Jual Obat Aborsi
 
Abortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy CytotecAbortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
uodye
 
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
wpkuukw
 
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
drmarathore
 
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
ehyxf
 
Abortion pills in Jeddah |+966572737505 | Get Cytotec
Abortion pills in Jeddah |+966572737505 | Get CytotecAbortion pills in Jeddah |+966572737505 | Get Cytotec
Abortion pills in Jeddah |+966572737505 | Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
ahmedjiabur940
 
Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
CRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptx
CRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptxCRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptx
CRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptx
Rishabh332761
 
一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理
一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理
一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理
uodye
 
怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证
怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证
怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证
ehyxf
 
在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一
在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一
在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一
uodye
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
tufbav
 
Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...
gajnagarg
 

Kürzlich hochgeladen (20)

Jual Obat Aborsi Samarinda ( No.1 ) 088980685493 Obat Penggugur Kandungan Cy...
Jual Obat Aborsi Samarinda (  No.1 ) 088980685493 Obat Penggugur Kandungan Cy...Jual Obat Aborsi Samarinda (  No.1 ) 088980685493 Obat Penggugur Kandungan Cy...
Jual Obat Aborsi Samarinda ( No.1 ) 088980685493 Obat Penggugur Kandungan Cy...
 
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
Abortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy CytotecAbortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy Cytotec
 
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
 
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
一比一定(购)新西兰林肯大学毕业证(Lincoln毕业证)成绩单学位证
 
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
 
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
怎样办理圣芭芭拉分校毕业证(UCSB毕业证书)成绩单留信认证
 
Abortion pills in Jeddah |+966572737505 | Get Cytotec
Abortion pills in Jeddah |+966572737505 | Get CytotecAbortion pills in Jeddah |+966572737505 | Get Cytotec
Abortion pills in Jeddah |+966572737505 | Get Cytotec
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
 
🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...
🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...
🌹Patia⬅️ Vip Call Girls Bhubaneswar 📱9777949614 Book Well Trand Call Girls In...
 
Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ratlam [ 7014168258 ] Call Me For Genuine Models We...
 
Low Cost Patna Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Gi...
Low Cost Patna Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Gi...Low Cost Patna Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Gi...
Low Cost Patna Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Gi...
 
CRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptx
CRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptxCRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptx
CRISIS COMMUNICATION presentation=-Rishabh(11195)-group ppt (4).pptx
 
Hilti's Latest Battery - Hire Depot.pptx
Hilti's Latest Battery - Hire Depot.pptxHilti's Latest Battery - Hire Depot.pptx
Hilti's Latest Battery - Hire Depot.pptx
 
一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理
一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理
一比一原版(USYD毕业证书)澳洲悉尼大学毕业证如何办理
 
怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证
怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证
怎样办理阿德莱德大学毕业证(Adelaide毕业证书)成绩单留信认证
 
在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一
在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一
在线制作(UQ毕业证书)昆士兰大学毕业证成绩单原版一比一
 
Call Girls Amethi 9332606886 HOT & SEXY Models beautiful and charming call g...
Call Girls Amethi  9332606886 HOT & SEXY Models beautiful and charming call g...Call Girls Amethi  9332606886 HOT & SEXY Models beautiful and charming call g...
Call Girls Amethi 9332606886 HOT & SEXY Models beautiful and charming call g...
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
 
Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Udgir [ 7014168258 ] Call Me For Genuine Models We ...
 

operating system (1).pdf

  • 2. Cpu scheduling objectives: ❖ Introduce CPU scheduling, which is the basis for multiprogrammed operating systems. ❖ Describe various cpu-scheduling algorithms. ❖ Discuss evaluation criteria for selecting a cpu-scheduling algorithm for a particular system.
  • 3. Introduction ❖ CPU scheduling is the task performed by CPU that decidesthe way processedwould be executed.CPU resources are allocated to a process for only a limited period of time and then those resources are taken back. A running process could be interrupted to execute a higher priority process. ❖ 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 systemefficient, fast and fair.
  • 4. Cpu scheduling basis for multiprogrammed operating system: CPU scheduling is the basis of multiprogrammed operating systems. By switching the CPU among processes, the operating system can make the computer more productive. In this chapter, we introduce basic CPU-scheduling concepts and present several CPU-scheduling algorithms.
  • 5. 2 Types of cpu scheduling: • Preemptive • Non preemptive
  • 6. Preemptive scheduling: Preemptive scheduling is when a processtransitions from a running state to a ready state or from a waiting state to a ready state. Most common and complex. Example: • when a higher priority task wants the CPU. • SRTF • Priority(preemptive) • RR
  • 7. Scheduling overhead: • Additional operations that take small amount of time • RR • SRTF • Priority (preemptive) • Multi-level feedback • Hybrid scheduling scheme
  • 8. Algorithms based on preemptive scheduling are: RoundRobin (RR),Shortest RemainingTime First (SRTF), Priority (preemptive version), etc.
  • 9. Non preemptive scheduling: Non-preemptive Scheduling is used when a process terminates,or a process switches from running to the waiting state.In this scheduling, once the resources (CPU cycles) are allocated to a process. In the case of non- preemptive scheduling does not interrupt a process running CPU in the middle of the execution. Instead, it waits till the process completes its CPU burst time, and then it can allocate the CPU to another process. Example: Non-preemptive Scheduling is rigid. ShortestRemaining Time First, Round Robin, First Come First Serve, Shortest Job First(non-preemptive), Priority Scheduling, etc.
  • 10. Algorithms based on non-preemptive scheduling are: Shortest Job First (SJF basicallynon preemptive) and Priority (non preemptive version), etc.
  • 11. How is scheduler invoked: ➢ Voluntarily • Process block due to I/o • Calls scheduler • E.g. FCFS, SJF ➢ Involuntarily • Preemption done by algorithm or timer • Kernal calls scheduler to take necessary action • E.g. SRTF ,RR
  • 12. Scheduler policy: ➢ Ideal • Selectable • Changeable ➢ Practical • Built-in os • Different versions may have different scheduling scheme ➢ Additional • Resource manager _ deadlock manager
  • 13. Control over scheduling: ➢ Interval timer • Time quantum _ static or dynamic ➢ Policy based • Interactive • Batch system • Real time application
  • 14. How policies are implemented: ➢ Mechanism behind working ➢ Requirement _ factors • Cpu utilization • Waiting time • Turnaround time ➢ Controls • Fair share among jobs • Favor given to different jobs • priorities
  • 15. Cpu scheduling algorithms: A Process Scheduler schedules different processes to be assigned to the CPU based on particular scheduling algorithms. There are six popular process scheduling algorithms which we are going to discuss in this chapter −
  • 16. Scheduling variables: • Set of processes • Set of states • Service time set • Waiting time • Turnaround time • Batch throughput • Time sharing time slice(if any)
  • 17. How to optimize scheduling algorithm? ➢ Scheduling function vs. Decision mode ➢ Define criteria to optimize • Scheduling criteria ➢ Use set of methods • Restrict no. of processes • Pre-determine service time • Compute run-time of all schedulers and decide the best
  • 18. Types of cpu scheduling algorithm: ➢First-Come, First-Served (FCFS) Scheduling ➢Shortest-Job-Next (SJN) Scheduling ➢Priority Scheduling ➢Shortest Remaining Time ➢Round Robin(RR) Scheduling ➢Multiple-Level Queues Scheduling
  • 19. First come first serve(FCFS) • Jobs are executed on first come, first serve basis. • It is a non-preemptive, pre-emptive scheduling algorithm. • Easy to understand and implement. • Its implementation is based on FIFO queue. • Poor in performance as average wait time is high.
  • 20.
  • 21. Waiting time of each process is as follows −
  • 22. Proces s Wait Time : Service Time - ArrivalTime P0 0 : 0 - 0 P1 4 : 5 - 1 P2 8 - 2 = 6 P3 16 - 3 = 13 Average Wait Time: (0+4+6+13) / 4 = 5.75
  • 23. Shortest job Next(SJN) • This is also known as shortest job first, or SJF • This is a non-preemptive, pre-emptive 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 required CPU time is not known. • The processer should know in advance how much time process will take.
  • 24.
  • 25. Waiting time of each process is as follows −
  • 26. Proces s Waiting Time P0 0 - 0 = 0 P1 5 - 1 = 4 P2 14 - 2 = 12 P3 8 - 3 = 5 Average Wait Time: (0 + 4 + 12 + 5)/4 = 21 / 4 = 5.25
  • 27. Priority Based Scheduling • Priority scheduling is a non-preemptive 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. • Processes with same priority are executed on first come first served basis. • Priority can be decided based on memory requirements, time requirements or any other resource requirement.
  • 28.
  • 29. Waiting time of each process is as follows −
  • 30. Process Waiting Time P0 0 - 0 = 0 P1 11 - 1 = 10 P2 14 - 2 = 12 P3 5 - 3 = 2 Average Wait Time: (0 + 10 + 12 + 2)/4 = 24 / 4 = 6
  • 31. 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 give preference.
  • 32.
  • 33. More and short term scheduler: ➢ Works in co-operation with dispatcher ➢ Frequently occurs and decides which process runs next ➢ Uses: • Clock interrupts • I/o interrupts • System calls • Traps or signals • Any blocking event ➢ Uses some algorithm and aims at scheduling criteria
  • 34. Round Robin(RR)Scheduling: • 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.
  • 35.
  • 36. Wait time of each process is as follows −
  • 37. Process Wait Time : Service Time - ArrivalTime P0 (0 - 0) + (12 - 3) = 9 P1 (3 - 1) = 2 P2 (6 - 2) + (14 - 9) + (20 - 17) = 12 P3 (9 - 3) + (17 - 12) = 11 Average Wait Time: (9+2+12+11) / 4 = 8.5
  • 38. Multiple-Level Queues 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.
  • 39. 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 queue and assigns them to the CPU based on the algorithm assigned to the queue.
  • 40.
  • 41. Short term scheduling on multi-processor systems: ➢ Load sharing • Global queue for processes • Central data structure that is properly synchronized • Even distribution among cpus ➢ Gang scheduling • 1:1 threads selected to be executed on a particular set of cpus ➢ Dedicated processes assignment • Assignment threads to specific processes ➢ Dynamic scheduling • No . of threads per application are altered by scheduler
  • 42. Multi-queue scheduling: ➢ Ready queue is partitioned into multiple queue • Real time vs. Batch processes ➢ Each queue has different scheduling algo • Set of algorithms ➢ Scheduling among queues • Fixed priority based • Time slice based
  • 43. Multiprocessor thread scheduling: ➢ Thread run on any cpu unless specified ➢ Affinity ▪ Soft • Scheduler tries to keep thread on the same cpu ▪ Hard • Threads are always bound to specific cpu
  • 45. What is dispatching: ➢Dispatcher is built – in os and works with short term scheduler ▪ Tells cpu about the newly selected process for execution ➢Various responsibilities: ▪ Determine the process at head of ready queue ▪ Preemption of current process – various reasons ▪ Context switch • Save stateof some process • Load stateof some process ➢Dispatchlatency ▪ Time taken by dispatcher to stop one and start another
  • 46.
  • 47. Mcqs OF CPU Scheduling
  • 48. 1. Round robin scheduling falls under the category of ____________ a) Non-preemptive scheduling b) Preemptive scheduling c) All of the mentioned d) None of the mentioned 2. With round robin scheduling algorithm in a time shared system ____________ a) using very large time slices converts it intoFirst come First served scheduling algorithm b) using very small time slices converts it intoFirst come First served scheduling algorithm c) using extremely small time slices increases performance d) using very small time slices converts it intoShortest Job First algorithm 3. The portion of the process scheduler in an operatingsystem that dispatches processes is concerned with ____________ a) assigning ready processes to CPU b) assigning ready processes to waitingqueue c) assigning running processes to blocked queue d) all of the mentioned
  • 49. 4. Complex scheduling algorithms ____________ a) are very appropriate for very large computers b) use minimal resources c) use many resources d) all of the mentioned 5. What is FIFO algorithm? a) first executes the job that came in last in the queue b) first executes the job that came in first in the queue c) first executes the job that needs minimal processor d) first executes the job that has maximum processor needs 6. The strategy of making processes that are logicallyrunnableto be temporarilysuspended is called ____________ a) Non preemptive scheduling b) Preemptive scheduling c) Shortest job first d) First come First served
  • 50. 7. What is Scheduling? a) allowing a job to use the processor b) making proper use of processor c) all of the mentioned d) none of the mentioned 8. There are 10 different processes running on a workstation.Idle processes are waiting for an input event in the input queue. Busy processes are scheduled with the Round-Robin timesharing method. Which out of the following quantum times is the best value for small response times, if the processes have a short runtime, e.g. less than 10ms? a) tQ = 15ms b) tQ = 40ms c) tQ = 45ms d) tQ = 50ms 9. Orders are processed in the sequence they arrive if _______ rule sequences the jobs. a) earliest due date b) slack time remaining c) first come, first served d) critical ratio
  • 51. 10. Which of the following algorithms tends to minimize the process flow time? a) First come First served b) Shortest Job First c) Earliest Deadline First d) Longest Job First 11. Under multiprogramming, turnaroundtime for short jobs is usually ________ and that for long jobs is slightly ___________ a) Lengthened; Shortened b) Shortened; Lengthened c) Shortened; Shortened d) Shortened; Unchanged 1. which of the followingcan not be scheduled by the kernel? A. process B. user-level thread C. kernel-level thread D. none of the mentioned
  • 52. •What is the base of CPU scheduling?​ •What is the purpose of CPU scheduling?​ •Which is the fastest CPU scheduling algorithm?​ •Why do we need scheduling?​ •What type of scheduling is FIFO?​ •What is shortest job first scheduling?​ •What are the 2 different types of scheduling queues?​ •Is FIFO and FCFS same?​ •Which is better SJF or RR?​ •What is deadlock in OS?​ Short questions: Cpu scheduling