The document discusses various aspects of process scheduling, including the goals, types (preemptive vs. non-preemptive), and criteria for effective scheduling in operating systems. It elaborates on common scheduling algorithms, their advantages, and disadvantages, as well as the importance of optimizing CPU utilization, throughput, and response time. Additionally, the document covers advanced concepts like multilevel queues and multilevel feedback queues to address the needs of different processes.
Overview of Process Scheduling presented by Sunawar Khan, highlighting its essential role in OS.
Discusses goals like maximizing CPU utilization, the concept of preemptive vs. non-preemptive scheduling, and the criteria and algorithms used in scheduling.
Details on scheduling levels: High, Intermediate, Low; and the differences between preemptive and non-preemptive scheduling.
Focuses on objectives of scheduling, listing criteria like CPU utilization, throughput, turnaround time, and response time.
Optimization criteria for scheduling algorithms, including utilization and throughput considerations.
Describes FIFO (First-In-First-Out) scheduling, its mechanism, and provides example scenarios illustrating its functionality.Round-Robin scheduling mechanisms, time quantum specifications, advantages, and examples illustrating performance variation.
Discussion on SPF scheduling, its advantages, challenges in predicting CPU burst times, and examples demonstrating scheduling impact.
Explains Multilevel Queue and Multilevel Feedback Queues, detailing their structure, algorithms, and approaches for optimizing process management.
Illustrative example showing the implementation of multilevel feedback queues with various time quantum and execution rules.
Reference:-
After Reading ThisTopic. . .
Goals of
processor
scheduling.
Preemptive
vs. Non
preemptive
scheduling.
Role of
priorities in
scheduling.
Scheduling
criteria.
Common
scheduling
algorithms.
3.
Reference:-
What is ProcessScheduling?
Assignment of Processor to process to accomplish the work
When process should be assigned to which process is Process Scheduling
When more than one process is runnable, UPU must decide priority
Part of OS concerned with this decision is called Scheduler.
To solve this problem with different algorithm is called Scheduling Algorithm
http://www.cs.kent.edu/~rmuhamma/
4.
Reference:-
Basic Concept
■ MaximumCPU utilization obtained
with multiprogramming
■ CPU–I/O Burst Cycle – Process
execution consists of a cycle of CPU
execution and I/O wait
■ CPU burst followed by I/O burst
■ CPU burst distribution is of main
concern
Silberchatz, Galvin and Gagne Operating System, 9th Edition
5.
Reference:-
Policy To ProcessScheduling
Decides which process runs at given time
Different schedulers goals Maximize throughput
Minimize latency
Prevent indefinite postponement
Complete process by given deadline
Maximize processor utilization
http://www.cs.kent.edu/~rmuhamma/
6.
Reference:-
What the Schedulertry to achieve
•Maximize throughput
•Response Time
•Minimize resource utilization
•Avoid indefinite postponement
•Enforce priorities
•Minimize overhead
•Ensure predictability
•Policy Enforcement
Different objectives depending on system
Deitel & Deitel, Operating System
Reference:-
Scheduling Levels
High-level
scheduling
•Determines whichjobs can compete for resources
•Controls number of processes in system at one time
Intermediate-
level
scheduling
•Determines which processes can compete for processors
•Responds to fluctuations in system load
Low-level
scheduling
•Assigns priorities
•Assigns processors to processes
Deitel & Deitel, Operating System
Reference:-
Preemptive vs. NonpreemptiveScheduling
Preemptive
processes
Can be removed from their current processor
Can lead to improved response times
Important for interactive environments
Preempted processes remain in memory
Nonpreemptive
processes
Run until completion or until they yield control of a
processor
Unimportant processes can block important ones
indefinitely
http://www.cs.kent.edu/~rmuhamma/
11.
Reference:-
CPU Scheduler
Short-termscheduler selects from among the processes in ready queue, and
allocates the CPU to one of them
Queue may be ordered in various ways
CPU scheduling decisions may take place when a process:
1. Switches from running to waiting state
2. Switches from running to ready state
3. Switches from waiting to ready
4. Terminates
Scheduling under 1 and 4 is nonpreemptive
All other scheduling is preemptive
Consider access to shared data
Consider preemption while in kernel mode
Consider interrupts occurring during crucial OS activities
Silberchatz, Galvin and Gagne Operating System, 9th Edition
12.
Reference:-
Scheduling Criteria
■ CPUutilization – keep the CPU as busy as possible
■ Throughput – # of processes that complete their execution per
time unit
■ Turnaround time – amount of time to execute a particular
process
■ Waiting time – amount of time a process has been waiting in
the ready queue
■ Response time – amount of time it takes from when a request
was submitted until the first response is produced, not output
(for time-sharing environment)
Silberchatz, Galvin and Gagne Operating System, 9th Edition
13.
Reference:-
Scheduling Algorithm OptimizationCriteria
■ Max CPU utilization
■ Max throughput
■ Min turnaround time
■ Min waiting time
■ Min response time
Silberchatz, Galvin and Gagne Operating System, 9th Edition
Reference:-
FIFO
Process Burst Time
P124
P2 3
P3 3
■ 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
P P P1 2 3
0 24 3027
17.
Reference:-
FIFO (Cont.)
Suppose thatthe processes arrive in the order:
P2 , P3 , P1
■ The Gantt chart for the schedule is:
■ Waiting time for P1 = 6; P2 = 0; P3 = 3
■ Average waiting time: (6 + 0 + 3)/3 = 3
■ Much better than previous case
■ Convoy effect - short process behind long process
– Consider one CPU-bound and many I/O-bound processes
P1
0 3 6 30
P2
P3
18.
Reference:-
Round-Robin (RR) Scheduling
■Round-robin scheduling
– Based on FIFO
– Processes run only for a limited amount of time called a time
slice or quantum
– Preemptible
– Requires the system to maintain several processes in memory
to minimize overhead
– Often used as part of more complex algorithms
19.
Reference:-
Round Robin(RR) Scheduling
■Each process gets a small unit of CPU time (time quantum q), 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.
■ Timer interrupts every quantum to schedule next process
■ Performance
– q large FIFO
– q small q must be large with respect to context switch, otherwise overhead is too
high
Reference:-
Example of RRwith Time Quantum = 4
Process Burst Time
P1 24
P2 3
P3 3
■ The Gantt chart is:
■ Typically, higher average turnaround than SJF, but better response
■ q should be large compared to context switch time
■ q usually 10ms to 100ms, context switch < 10 usec
P P P1 1 1
0 18 3026144 7 10 22
P2
P3
P1
P1
P1
Reference:-24
Round-Robin (RR) Scheduling
■Selfish round-robin scheduling
– Increases priority as process ages
– Two queues
■ Active
■ Holding
– Favors older processes to avoids unreasonable
delays
25.
Reference:-25
Round-Robin (RR) Scheduling
■Quantum size
– Determines response time to interactive requests
– Very large quantum size
■ Processes run for long periods
■ Degenerates to FIFO
– Very small quantum size
■ System spends more time context switching than running processes
– Middle-ground
■ Long enough for interactive processes to issue I/O request
■ Batch processes still get majority of processor time
26.
Reference:-
Shortest-Process-First (SPF) Scheduling
■Scheduler selects process with smallest time to finish
– Lower average wait time than FIFO
■ Reduces the number of waiting processes
– Potentially large variance in wait times
– Nonpreemptive
■ Results in slow response times to arriving interactive requests
– Relies on estimates of time-to-completion
■ Can be inaccurate or falsified
– Unsuitable for use in modern interactive systems
27.
Reference:-
Shortest-Process-First (SPF) Scheduling
■Associate with each process the length of its next CPU
burst
– Use these lengths to schedule the process with the
shortest time
■ SJF is optimal – gives minimum average waiting time for a
given set of processes
– The difficulty is knowing the length of the next CPU
request
– Could ask the user
28.
Reference:-
Example of SJF
ProcessArrival Time Burst Time
P1 0.0 6
P2 2.0 8
P3 4.0 7
P4 5.0 3
■ SJF scheduling chart
■ Average waiting time = (3 + 16 + 9 + 0) / 4 = 7
P3
0 3 24
P4
P1
169
P2
29.
Reference:-
Determining Length ofNext CPU Burst
■ Can only estimate the length – should be similar to the previous one
– Then pick process with shortest predicted next CPU burst
■ Can be done by using the length of previous CPU bursts, using
exponential averaging
■ Commonly, α set to ½
■ Preemptive version called shortest-remaining-time-first
:Define4.
10,3.
burstCPUnexttheforvaluepredicted2.
burstCPUoflengthactual1.
1n
th
n nt
.11 nnn t
Reference:-
Examples of ExponentialAveraging
■ =0
– n+1 = n
– Recent history does not count
■ =1
– n+1 = tn
– Only the actual last CPU burst counts
■ If we expand the formula, we get:
n+1 = tn+(1 - ) tn -1 + …
+(1 - )j tn -j + …
+(1 - )n +1 0
■ Since both and (1 - ) are less than or equal to 1, each successive term has less
weight than its predecessor
32.
Reference:-
Example of Shortest-remaining-time-first
■Now we add the concepts of varying arrival times and preemption to the analysis
ProcessAarri Arrival TimeT Burst Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5
■ Preemptive SJF Gantt Chart
■ Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 msec
P4
0 1 26
P1
P2
10
P3
P1
5 17
33.
Reference:-
Multilevel Queue
■ Readyqueue is partitioned into separate queues, eg:
– foreground (interactive)
– background (batch)
■ Process permanently in a given queue
■ Each queue has its own scheduling algorithm:
– foreground – RR
– background – FCFS
■ Scheduling must be done between the queues:
– Fixed priority scheduling; (i.e., serve all from foreground then from background).
Possibility of starvation.
– Time slice – each queue gets a certain amount of CPU time which it can schedule
amongst its processes; i.e., 80% to foreground in RR
– 20% to background in FCFS
34.
Reference:-34
Multilevel Feedback Queues
■Different processes have different needs
– Short I/O-bound interactive processes should generally run before
processor-bound batch processes
– Behavior patterns not immediately obvious to the scheduler
■ Multilevel feedback queues
– Arriving processes enter the highest-level queue and execute with higher
priority than processes in lower queues
– Long processes repeatedly descend into lower levels
■ Gives short processes and I/O-bound processes higher priority
■ Long processes will run when short and I/O-bound processes terminate
– Processes in each queue are serviced using round-robin
■ Process entering a higher-level queue preempt running processes
35.
Reference:-35
Multilevel Feedback Queues
■Algorithm must respond to changes in environment
– Move processes to different queues as they alternate between
interactive and batch behavior
■ Example of an adaptive mechanism
– Adaptive mechanisms incur overhead that often is offset by
increased sensitivity to process behavior
Reference:-
Multilevel Feedback Queue
■A process can move between the various queues; aging can be
implemented this way
■ Multilevel-feedback-queue scheduler defined by the following
parameters:
– number of queues
– scheduling algorithms for each queue
– method used to determine when to upgrade 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
39.
Reference:-
Example of MultilevelFeedback Queue
■ Three queues:
– Q0 – RR with time quantum 8 milliseconds
– Q1 – RR time quantum 16 milliseconds
– Q2 – FCFS
■ Scheduling
– A new job enters queue Q0 which is served
FCFS
■ When it gains CPU, job receives 8
milliseconds
■ If it does not finish in 8
milliseconds, job is moved to queue
Q1
– At Q1 job is again served FCFS and
receives 16 additional milliseconds
■ If it still does not complete, it is
preempted and moved to queue Q2