SlideShare a Scribd company logo
1 of 24
1
““Windows Scheduling Algorithm””
ADVANCE OPERATING SYSTEM
Basic ConceptsBasic Concepts
 Maximum CPU utilization is obtained with multiprogramming
◦ Several processes are kept in memory at one time
◦ Every time a running process has to wait, another process can take over use of
the CPU
 Scheduling of the CPU is fundamental to operating system design
 Process execution consists of a cycle of a CPU time burst and an I/O time burst
(i.e. wait)
◦ Processes alternate between these two states (i.e., CPU burst and I/O burst)
◦ Eventually, the final CPU burst ends with a system request to terminate
execution
Alternating Sequence of CPUAlternating Sequence of CPU
And I/O BurstsAnd I/O Bursts
CPU SchedulerCPU Scheduler
 The CPU scheduler selects from among the processes in memory that are ready to
execute and allocates the CPU to one of them
 CPU scheduling is affected by the following set of circumstances:
(N) A process switches from running to waiting state
(P) A process switches from running to ready state
(P) A process switches from waiting to ready state
(N) A processes switches from running to terminated state
 Circumstances 1 and 4 are non-preemptive; they offer no schedule choice
 Circumstances 2 and 3 are pre-emptive; they can be scheduled
Scheduling CriteriaScheduling Criteria
Different CPU scheduling algorithms have different properties
 In choosing which algorithm to use, the properties of the various algorithms should
be considered
 Criteria for comparing CPU scheduling algorithms may include the following
◦ CPU utilization – percent of time that the CPU is busy executing a process
◦ Throughput – number of processes that are completed per time unit
◦ Response time – amount of time it takes from when a request was submitted
until the first response occurs (but not the time it takes to output the entire
response)
◦ Waiting time – the amount of time before a process starts after first entering the
ready queue (or the sum of the amount of time a process has spent waiting in the
ready queue)
◦ Turnaround time – amount of time to execute a particular process from the time
of submission through the time of completion
Optimization CriteriaOptimization Criteria
 It is desirable to
◦ Maximize CPU utilization
◦ Maximize throughput
◦ Minimize turnaround time
◦ Minimize start time
◦ Minimize waiting time
◦ Minimize response time
 In most cases, we strive to optimize the average measure of each metric
 In other cases, it is more important to optimize the minimum or maximum values
rather than the average
 First Come, First Served (FCFS)
 Shortest Job First (SJF)
 Priority
 Round Robin (RR)
SINGLE PROCESSOR SCHEDULINGSINGLE PROCESSOR SCHEDULING
ALGORITHMSALGORITHMS
ProcessBurst Time
P1 24
P2 3
P3 3
 With FCFS, the process that requests the CPU first is allocated the CPU first
 Case #1: Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:
 Waiting time for P1 = 0; P2 = 24; P3 = 27
 Average waiting time: (0 + 24 + 27)/3 = 17
 Average turn-around time: (24 + 27 + 30)/3 = 27
FIRST-COME, FIRST-SERVED (FCFS)FIRST-COME, FIRST-SERVED (FCFS)
SCHEDULINGSCHEDULING
P1 P2 P3
24 27 300
FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)
 Case #2: Suppose that the processes arrive in the order: P2 , P3 , P1
 The Gantt chart for the schedule is:
P1P3P2
63 300
Waiting time for P1 = 6; P2 = 0; P3 = 3
Average waiting time: (6 + 0 + 3)/3 = 3 (Much better than Case #1)
Average turn-around time: (3 + 6 + 30)/3 = 13
FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)
 Case #1 is an example of the convoy effect; all the other processes wait for one
long-running process to finish using the CPU
◦ This problem results in lower CPU and device utilization;
 Case #2 shows that higher utilization might be possible if the short processes
were allowed to run first
 The FCFS scheduling algorithm is non-preemptive
◦ Once the CPU has been allocated to a process, that process keeps the CPU until
it releases it either by terminating or by requesting I/O
◦ It is a troublesome algorithm for time-sharing systems
Priority SchedulingPriority Scheduling
 The SJF algorithm is a special case of the general priority scheduling algorithm
 A priority number (integer) is associated with each process
 The CPU is allocated to the process with the highest priority (smallest integer =
highest priority)
 Priority scheduling can be either preemptive or non-preemptive
◦ A preemptive approach will preempt the CPU if the priority of the newly-arrived
process is higher than the priority of the currently running process
◦ A non-preemptive approach will simply put the new process (with the highest
priority) at the head of the ready queue
 SJF is a priority scheduling algorithm where priority is the predicted next CPU
burst time
 The main problem with priority scheduling is starvation, that is, low priority
processes may never execute
 A solution is aging; as time progresses, the priority of a process in the ready queue
is increased
ROUND ROBIN (RR) SCHEDULINGROUND ROBIN (RR) SCHEDULING
•In the round robin algorithm, each process gets a small unit of CPU time (a time
quantum), usually 10-100 milliseconds. After this time has elapsed, the process is
preempted and added to the end of the ready queue.
•If there are n processes in the ready queue and the time quantum is q, then each
process gets 1/n of the CPU time in chunks of at most q time units at once. No process
waits more than (n-1)q time units.
•Performance of the round robin algorithm
•q large  FCFS
•q small  q must be greater than the context switch time; otherwise, the overhead
is too high
•One rule of thumb is that 80% of the CPU bursts should be shorter than the time
quantum
Process Burst Time
P1 53
P2 17
P3 68
P4 24
 The Gantt chart is:
EXAMPLE OF RR WITH TIMEEXAMPLE OF RR WITH TIME
QUANTUM = 20QUANTUM = 20
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
0 20 37 57 77 97 117 121 134 154 162
Example of RR with TimeExample of RR with Time
Quantum = 20Quantum = 20
 Typically, higher average turnaround than SJF, but better response time
 Average waiting time
= ( [(0 – 0) + (77 - 20) + (121 – 97)] + (20 – 0) + [(37 – 0) + (97 - 57) +
(134 – 117)] + [(57 – 0) + (117 – 77)] ) / 4
= (0 + 57 + 24) + 20 + (37 + 40 + 17) + (57 + 40) ) / 4
= (81 + 20 + 94 + 97)/4
= 292 / 4 = 73
 Average turn-around time = 134 + 37 + 162 + 121) / 4 = 113.5
 In multi-level feedback queue scheduling, a process can move between the various
queues; aging can be implemented this way
 A multilevel-feedback-queue scheduler is defined by the following parameters:
◦ Number of queues
◦ Scheduling algorithms for each queue
◦ Method used to determine when to promote a process
◦ Method used to determine when to demote a process
◦ Method used to determine which queue a process will enter when that process
needs service
MULTILEVEL FEEDBACK QUEUEMULTILEVEL FEEDBACK QUEUE
SCHEDULINGSCHEDULING
EXAMPLE OF MULTILEVEL FEEDBACKEXAMPLE OF MULTILEVEL FEEDBACK
QUEUEQUEUE
 Scheduling
◦ A new job enters queue Q0 (RR) and is placed at the end. When it gains the
CPU, the job receives 8 milliseconds. If it does not finish in 8 milliseconds, the
job is moved to the end of queue Q1.
◦ A Q1 (RR) job receives 16 milliseconds. If it still does not complete, it is
preempted and moved to queue Q2 (FCFS).
WINDOWS XP SCHEDULINGWINDOWS XP SCHEDULING
 Windows XP schedules threads using a priority-based, preemptive scheduling
algorithm
 The scheduler ensures that the highest priority thread will always run
 The portion of the Windows kernel that handles scheduling is called the
dispatcher
 A thread selected to run by the dispatcher will run until it is preempted by a
higher-priority thread, until it terminates, until its time quantum ends, or until it
calls a blocking system call such as I/O
 If a higher-priority real-time thread becomes ready while a lower-priority thread
is running, lower-priority thread will be preempted
◦ This preemption gives a real-time thread preferential access to the CPU when
the thread needs such access
 The dispatcher uses a 32-level priority scheme to determine the order of thread
execution
 Priorities are divided into two classes
◦ The variable class contains threads having priorities 1 to 15
◦ The real-time class contains threads with priorities ranging from 16 to 31
◦ There is also a thread running at priority 0 that is used for memory management
 The dispatcher uses a queue for each scheduling priority and traverses the set of
queues from highest to lowest until it finds a thread that is ready to run
 If no ready thread is found, the dispatcher will execute a special thread called the
idle thread
WINDOWS XP SCHEDULINGWINDOWS XP SCHEDULING
Windows XP SchedulingWindows XP Scheduling
 There is a relationship between the numeric priorities of the Windows XP kernel
and the Win32 API
 The Windows Win32 API identifies six priority classes to which a process can
belong as shown below
◦ Real-time priority class
◦ High priority class
◦ Above normal priority class
◦ Normal priority class
◦ Below normal priority class
◦ Low priority class
 Priorities in all classes except the read-time priority class are variable
◦ This means that the priority of a thread in one of these classes can change
Windows XP SchedulingWindows XP Scheduling
 Within each of the priority classes is a relative priority as shown below
 The priority of each thread is based on the priority class it belongs to and its relative
priority within that class
Windows XP SchedulingWindows XP Scheduling
 The initial priority of a thread is typically the base priority of the process that the
thread belongs to
 When a thread’s time quantum runs out, that thread is interrupted
 If the thread is in the variable-priority class, its priority is lowered
◦ However, the priority is never lowered below the base priority
 Lowering the thread’s priority tends to limit the CPU consumption of compute-
bound threads
Windows XP SchedulingWindows XP Scheduling
When a variable-priority thread is released from a wait operation, the
dispatcher boosts the priority
The amount of boost depends on what the thread was waiting for
A thread that was waiting for keyboard I/O would get a large increase
A thread that was waiting for a disk operation would get a moderate
increase
This strategy tends to give good response time to interactive threads that are
using the mouse and windows
It also enables I/O-bound threads to keep the I/O devices busy while
permitting compute-bound threads to use spare CPU cycles in the background
This strategy is used by several time-sharing operating systems, including
UNIX
In addition, the window with which the user is currently interacting receives a
priority boost to enhance its response time
Windows XP SchedulingWindows XP Scheduling
 When a user is running an interactive program, the system needs to provide
especially good performance for that process
 Therefore, Windows XP has a special scheduling rule for processes in the normal
priority class
 Windows XP distinguishes between the foreground process that is currently
selected on the screen and the background processes that are not currently selected
 When a process moves in the foreground, Windows XP increases the scheduling
quantum by some factor – typically by 3
 This increase gives the foreground process three times longer to run before a time-
sharing preemption occurs
THANK YOUTHANK YOU

More Related Content

What's hot

17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
myrajendra
 

What's hot (20)

Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
 
Process creation and termination In Operating System
Process creation and termination In Operating SystemProcess creation and termination In Operating System
Process creation and termination In Operating System
 
Linux scheduling and input and output
Linux scheduling and input and outputLinux scheduling and input and output
Linux scheduling and input and output
 
Real time operating systems (rtos) concepts 1
Real time operating systems (rtos) concepts 1Real time operating systems (rtos) concepts 1
Real time operating systems (rtos) concepts 1
 
VTU 6th Sem Elective CSE - Module 3 cloud computing
VTU 6th Sem Elective CSE - Module 3 cloud computingVTU 6th Sem Elective CSE - Module 3 cloud computing
VTU 6th Sem Elective CSE - Module 3 cloud computing
 
Process scheduling linux
Process scheduling linuxProcess scheduling linux
Process scheduling linux
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
 
Parallel processing (simd and mimd)
Parallel processing (simd and mimd)Parallel processing (simd and mimd)
Parallel processing (simd and mimd)
 
Process control block(PCB)
Process control block(PCB)Process control block(PCB)
Process control block(PCB)
 
Superscalar processor
Superscalar processorSuperscalar processor
Superscalar processor
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memory
 
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
SOLUTION MANUAL OF OPERATING SYSTEM CONCEPTS BY ABRAHAM SILBERSCHATZ, PETER B...
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Priority levels in Windows
Priority levels in WindowsPriority levels in Windows
Priority levels in Windows
 
Kernels and its types
Kernels and its typesKernels and its types
Kernels and its types
 
Understanding IIS
Understanding IISUnderstanding IIS
Understanding IIS
 
Os Linux
Os LinuxOs Linux
Os Linux
 

Viewers also liked

Win8 architecture for developers
Win8 architecture for developersWin8 architecture for developers
Win8 architecture for developers
Robert MacLean
 
(07) instalaã§ã£o de programas
(07) instalaã§ã£o de programas(07) instalaã§ã£o de programas
(07) instalaã§ã£o de programas
Anderson Lago
 
Processes and Threads in Windows Vista
Processes and Threads in Windows VistaProcesses and Threads in Windows Vista
Processes and Threads in Windows Vista
Trinh Phuc Tho
 
Context Switching
Context SwitchingContext Switching
Context Switching
franksvalli
 
(08)inicializacao e gerencia_de_processos
(08)inicializacao e gerencia_de_processos(08)inicializacao e gerencia_de_processos
(08)inicializacao e gerencia_de_processos
Anderson Lago
 

Viewers also liked (20)

The Windows Scheduler
The Windows SchedulerThe Windows Scheduler
The Windows Scheduler
 
CPU scheduling algorithms in OS
CPU scheduling algorithms in OSCPU scheduling algorithms in OS
CPU scheduling algorithms in OS
 
scheduling algorithm
scheduling algorithmscheduling algorithm
scheduling algorithm
 
Grds conferences icst and icbelsh (5)
Grds conferences icst and icbelsh (5)Grds conferences icst and icbelsh (5)
Grds conferences icst and icbelsh (5)
 
Win8 architecture for developers
Win8 architecture for developersWin8 architecture for developers
Win8 architecture for developers
 
Cryptography make easy
Cryptography make easyCryptography make easy
Cryptography make easy
 
Advanced cryptography and implementation
Advanced cryptography and implementationAdvanced cryptography and implementation
Advanced cryptography and implementation
 
Loss Monitor
Loss MonitorLoss Monitor
Loss Monitor
 
Processor / CPU Scheduling
Processor / CPU SchedulingProcessor / CPU Scheduling
Processor / CPU Scheduling
 
(07) instalaã§ã£o de programas
(07) instalaã§ã£o de programas(07) instalaã§ã£o de programas
(07) instalaã§ã£o de programas
 
Processes and Threads in Windows Vista
Processes and Threads in Windows VistaProcesses and Threads in Windows Vista
Processes and Threads in Windows Vista
 
Round Robin Scheduling Algorithm (Simulation)
Round Robin Scheduling Algorithm (Simulation)Round Robin Scheduling Algorithm (Simulation)
Round Robin Scheduling Algorithm (Simulation)
 
Chapter6 threads
Chapter6 threadsChapter6 threads
Chapter6 threads
 
AIX - Gerência de Processos
AIX - Gerência de ProcessosAIX - Gerência de Processos
AIX - Gerência de Processos
 
Context Switching
Context SwitchingContext Switching
Context Switching
 
Operating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - SchedulingOperating Systems 1 (10/12) - Scheduling
Operating Systems 1 (10/12) - Scheduling
 
VLIW Processors
VLIW ProcessorsVLIW Processors
VLIW Processors
 
Windows xp
Windows   xpWindows   xp
Windows xp
 
Gerência de Processos: Deadlocks
Gerência de Processos: DeadlocksGerência de Processos: Deadlocks
Gerência de Processos: Deadlocks
 
(08)inicializacao e gerencia_de_processos
(08)inicializacao e gerencia_de_processos(08)inicializacao e gerencia_de_processos
(08)inicializacao e gerencia_de_processos
 

Similar to Window scheduling algorithm (20)

Ch05 cpu-scheduling
Ch05 cpu-schedulingCh05 cpu-scheduling
Ch05 cpu-scheduling
 
Ch05
Ch05Ch05
Ch05
 
cpu sechduling
cpu sechduling cpu sechduling
cpu sechduling
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Ch6
Ch6Ch6
Ch6
 
Process management in os
Process management in osProcess management in os
Process management in os
 
Ch5
Ch5Ch5
Ch5
 
OS_Ch6
OS_Ch6OS_Ch6
OS_Ch6
 
OSCh6
OSCh6OSCh6
OSCh6
 
Cpu_sheduling.pptx
Cpu_sheduling.pptxCpu_sheduling.pptx
Cpu_sheduling.pptx
 
CH06.pdf
CH06.pdfCH06.pdf
CH06.pdf
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Os2
Os2Os2
Os2
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 
Scheduling algo(by HJ)
Scheduling algo(by HJ)Scheduling algo(by HJ)
Scheduling algo(by HJ)
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Csc4320 chapter 5 2
Csc4320 chapter 5 2Csc4320 chapter 5 2
Csc4320 chapter 5 2
 
Os..
Os..Os..
Os..
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
 
Operating System Scheduling
Operating System SchedulingOperating System Scheduling
Operating System Scheduling
 

Recently uploaded

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
Health
 

Recently uploaded (20)

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 

Window scheduling algorithm

  • 2. Basic ConceptsBasic Concepts  Maximum CPU utilization is obtained with multiprogramming ◦ Several processes are kept in memory at one time ◦ Every time a running process has to wait, another process can take over use of the CPU  Scheduling of the CPU is fundamental to operating system design  Process execution consists of a cycle of a CPU time burst and an I/O time burst (i.e. wait) ◦ Processes alternate between these two states (i.e., CPU burst and I/O burst) ◦ Eventually, the final CPU burst ends with a system request to terminate execution
  • 3. Alternating Sequence of CPUAlternating Sequence of CPU And I/O BurstsAnd I/O Bursts
  • 4. CPU SchedulerCPU Scheduler  The CPU scheduler selects from among the processes in memory that are ready to execute and allocates the CPU to one of them  CPU scheduling is affected by the following set of circumstances: (N) A process switches from running to waiting state (P) A process switches from running to ready state (P) A process switches from waiting to ready state (N) A processes switches from running to terminated state  Circumstances 1 and 4 are non-preemptive; they offer no schedule choice  Circumstances 2 and 3 are pre-emptive; they can be scheduled
  • 5. Scheduling CriteriaScheduling Criteria Different CPU scheduling algorithms have different properties  In choosing which algorithm to use, the properties of the various algorithms should be considered  Criteria for comparing CPU scheduling algorithms may include the following ◦ CPU utilization – percent of time that the CPU is busy executing a process ◦ Throughput – number of processes that are completed per time unit ◦ Response time – amount of time it takes from when a request was submitted until the first response occurs (but not the time it takes to output the entire response) ◦ Waiting time – the amount of time before a process starts after first entering the ready queue (or the sum of the amount of time a process has spent waiting in the ready queue) ◦ Turnaround time – amount of time to execute a particular process from the time of submission through the time of completion
  • 6. Optimization CriteriaOptimization Criteria  It is desirable to ◦ Maximize CPU utilization ◦ Maximize throughput ◦ Minimize turnaround time ◦ Minimize start time ◦ Minimize waiting time ◦ Minimize response time  In most cases, we strive to optimize the average measure of each metric  In other cases, it is more important to optimize the minimum or maximum values rather than the average
  • 7.  First Come, First Served (FCFS)  Shortest Job First (SJF)  Priority  Round Robin (RR) SINGLE PROCESSOR SCHEDULINGSINGLE PROCESSOR SCHEDULING ALGORITHMSALGORITHMS
  • 8. ProcessBurst Time P1 24 P2 3 P3 3  With FCFS, the process that requests the CPU first is allocated the CPU first  Case #1: Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is:  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17  Average turn-around time: (24 + 27 + 30)/3 = 27 FIRST-COME, FIRST-SERVED (FCFS)FIRST-COME, FIRST-SERVED (FCFS) SCHEDULINGSCHEDULING P1 P2 P3 24 27 300
  • 9. FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)  Case #2: Suppose that the processes arrive in the order: P2 , P3 , P1  The Gantt chart for the schedule is: P1P3P2 63 300 Waiting time for P1 = 6; P2 = 0; P3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 (Much better than Case #1) Average turn-around time: (3 + 6 + 30)/3 = 13
  • 10. FCFS Scheduling (Cont.)FCFS Scheduling (Cont.)  Case #1 is an example of the convoy effect; all the other processes wait for one long-running process to finish using the CPU ◦ This problem results in lower CPU and device utilization;  Case #2 shows that higher utilization might be possible if the short processes were allowed to run first  The FCFS scheduling algorithm is non-preemptive ◦ Once the CPU has been allocated to a process, that process keeps the CPU until it releases it either by terminating or by requesting I/O ◦ It is a troublesome algorithm for time-sharing systems
  • 11. Priority SchedulingPriority Scheduling  The SJF algorithm is a special case of the general priority scheduling algorithm  A priority number (integer) is associated with each process  The CPU is allocated to the process with the highest priority (smallest integer = highest priority)  Priority scheduling can be either preemptive or non-preemptive ◦ A preemptive approach will preempt the CPU if the priority of the newly-arrived process is higher than the priority of the currently running process ◦ A non-preemptive approach will simply put the new process (with the highest priority) at the head of the ready queue  SJF is a priority scheduling algorithm where priority is the predicted next CPU burst time  The main problem with priority scheduling is starvation, that is, low priority processes may never execute  A solution is aging; as time progresses, the priority of a process in the ready queue is increased
  • 12. ROUND ROBIN (RR) SCHEDULINGROUND ROBIN (RR) SCHEDULING •In the round robin algorithm, each process gets a small unit of CPU time (a time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. •If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units. •Performance of the round robin algorithm •q large  FCFS •q small  q must be greater than the context switch time; otherwise, the overhead is too high •One rule of thumb is that 80% of the CPU bursts should be shorter than the time quantum
  • 13. Process Burst Time P1 53 P2 17 P3 68 P4 24  The Gantt chart is: EXAMPLE OF RR WITH TIMEEXAMPLE OF RR WITH TIME QUANTUM = 20QUANTUM = 20 P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162
  • 14. Example of RR with TimeExample of RR with Time Quantum = 20Quantum = 20  Typically, higher average turnaround than SJF, but better response time  Average waiting time = ( [(0 – 0) + (77 - 20) + (121 – 97)] + (20 – 0) + [(37 – 0) + (97 - 57) + (134 – 117)] + [(57 – 0) + (117 – 77)] ) / 4 = (0 + 57 + 24) + 20 + (37 + 40 + 17) + (57 + 40) ) / 4 = (81 + 20 + 94 + 97)/4 = 292 / 4 = 73  Average turn-around time = 134 + 37 + 162 + 121) / 4 = 113.5
  • 15.  In multi-level feedback queue scheduling, a process can move between the various queues; aging can be implemented this way  A multilevel-feedback-queue scheduler is defined by the following parameters: ◦ Number of queues ◦ Scheduling algorithms for each queue ◦ Method used to determine when to promote a process ◦ Method used to determine when to demote a process ◦ Method used to determine which queue a process will enter when that process needs service MULTILEVEL FEEDBACK QUEUEMULTILEVEL FEEDBACK QUEUE SCHEDULINGSCHEDULING
  • 16. EXAMPLE OF MULTILEVEL FEEDBACKEXAMPLE OF MULTILEVEL FEEDBACK QUEUEQUEUE  Scheduling ◦ A new job enters queue Q0 (RR) and is placed at the end. When it gains the CPU, the job receives 8 milliseconds. If it does not finish in 8 milliseconds, the job is moved to the end of queue Q1. ◦ A Q1 (RR) job receives 16 milliseconds. If it still does not complete, it is preempted and moved to queue Q2 (FCFS).
  • 17. WINDOWS XP SCHEDULINGWINDOWS XP SCHEDULING  Windows XP schedules threads using a priority-based, preemptive scheduling algorithm  The scheduler ensures that the highest priority thread will always run  The portion of the Windows kernel that handles scheduling is called the dispatcher  A thread selected to run by the dispatcher will run until it is preempted by a higher-priority thread, until it terminates, until its time quantum ends, or until it calls a blocking system call such as I/O  If a higher-priority real-time thread becomes ready while a lower-priority thread is running, lower-priority thread will be preempted ◦ This preemption gives a real-time thread preferential access to the CPU when the thread needs such access
  • 18.  The dispatcher uses a 32-level priority scheme to determine the order of thread execution  Priorities are divided into two classes ◦ The variable class contains threads having priorities 1 to 15 ◦ The real-time class contains threads with priorities ranging from 16 to 31 ◦ There is also a thread running at priority 0 that is used for memory management  The dispatcher uses a queue for each scheduling priority and traverses the set of queues from highest to lowest until it finds a thread that is ready to run  If no ready thread is found, the dispatcher will execute a special thread called the idle thread WINDOWS XP SCHEDULINGWINDOWS XP SCHEDULING
  • 19. Windows XP SchedulingWindows XP Scheduling  There is a relationship between the numeric priorities of the Windows XP kernel and the Win32 API  The Windows Win32 API identifies six priority classes to which a process can belong as shown below ◦ Real-time priority class ◦ High priority class ◦ Above normal priority class ◦ Normal priority class ◦ Below normal priority class ◦ Low priority class  Priorities in all classes except the read-time priority class are variable ◦ This means that the priority of a thread in one of these classes can change
  • 20. Windows XP SchedulingWindows XP Scheduling  Within each of the priority classes is a relative priority as shown below  The priority of each thread is based on the priority class it belongs to and its relative priority within that class
  • 21. Windows XP SchedulingWindows XP Scheduling  The initial priority of a thread is typically the base priority of the process that the thread belongs to  When a thread’s time quantum runs out, that thread is interrupted  If the thread is in the variable-priority class, its priority is lowered ◦ However, the priority is never lowered below the base priority  Lowering the thread’s priority tends to limit the CPU consumption of compute- bound threads
  • 22. Windows XP SchedulingWindows XP Scheduling When a variable-priority thread is released from a wait operation, the dispatcher boosts the priority The amount of boost depends on what the thread was waiting for A thread that was waiting for keyboard I/O would get a large increase A thread that was waiting for a disk operation would get a moderate increase This strategy tends to give good response time to interactive threads that are using the mouse and windows It also enables I/O-bound threads to keep the I/O devices busy while permitting compute-bound threads to use spare CPU cycles in the background This strategy is used by several time-sharing operating systems, including UNIX In addition, the window with which the user is currently interacting receives a priority boost to enhance its response time
  • 23. Windows XP SchedulingWindows XP Scheduling  When a user is running an interactive program, the system needs to provide especially good performance for that process  Therefore, Windows XP has a special scheduling rule for processes in the normal priority class  Windows XP distinguishes between the foreground process that is currently selected on the screen and the background processes that are not currently selected  When a process moves in the foreground, Windows XP increases the scheduling quantum by some factor – typically by 3  This increase gives the foreground process three times longer to run before a time- sharing preemption occurs