Ch4 Cpu Scheduling
Ch4 Cpu Scheduling
Ch4 Cpu Scheduling
CPU Scheduling
CHAPTER 4: CPU SCHEDULING
• Basic Concepts
• Scheduling Criteria
• Scheduling Algorithms
• Thread Scheduling
• Multiple-Processor Scheduling
• Real-Time CPU Scheduling
• Operating Systems Examples
• Algorithm Evaluation
OBJECTIVES
P2 P3 P1
0 3 6 30
P4 P1 P3 P2
0 3 9 16 24
• Can only estimate the length – should be similar to the previous one
• Then pick process with shortest predicted next CPU burst
• Commonly, α set to ½
• Preemptive version called shortest-remaining-time-first
PREDICTION OF THE LENGTH OF THE NEXT CPU BURST
EXAMPLES OF EXPONENTIAL AVERAGING
• =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
• 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
P1 P2 P4 P1 P3
0 1 5 10 17 26
• The CPU is allocated to the process with the highest priority (smallest
integer highest priority)
• Preemptive
• Nonpreemptive
ملغي
• 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
EXAMPLE OF MULTILEVEL FEEDBACK QUEUE
• 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
END OF CHAPTER 4