Download presentation
Presentation is loading. Please wait.
Published byDavid Bridges Modified over 9 years ago
1
scanf n, a, b /* I-O wait */ for (i=1; i<=n; i++) /* CPU burst */ x = x + a*b; printf x /* I-O wait */ for (i=1; i<=n; i++) /* CPU burst */ x = x + a*b; printf x /* I-O wait */ waiting time Sum of periods spent waiting in ready queue Average is across all visits to ready queue Goal: short waiting time
2
First-Come, First-Served is simplest scheduling algorithm Ready queue is a FIFO queue: First-In, First- Out Nonpreemptive : executes until voluntarily gives up CPU Problems.
3
Assume processes arrive in this order: P1, P2, P3 Nonpreemptive scheduling Gantt chart Average waiting time: (0+24+27)/3 = 17 ms PIDBurst P124 P23 P33 P1P2P3
4
Assume processes arrive in this order: P2, P3, P1 Nonpreemptive scheduling Gantt chart Average waiting time: (6+0+3)/3 = 3 ms PIDBurst P23 P33 P124 P2P3P1
5
Shortest -Job- First Assume the next burst time of each process is known SJF selects process which has the shortest burst time Nonpreemptive or preemptive(Not included in the course project) Shortest-remaining-time-first Interrupts running process if a new process enters the queue new process must have shorter burst than remaining time
6
Assume all processes arrive at the same time: P1, P2, P3, P4 Nonpreemptive scheduling Gantt chart Average waiting time: (3+16+9+0)/4=7 ms PIDBurst P16 P28 P37 P43 P1P3P2
7
Switch between processes Time quantum is a small unit of time (10 to 100 ms) Process is executed on the CPU for at most one time quantum Implemented by using the ready queue as a circular queue Head process gets the CPU Uses less than a time quantum IMPLIES gives up the CPU voluntarily Uses full time quantum IMPLIES timer will cause an interrupt Context switch will be executed Process will be put at the tail of queue
8
Assume processes arrive in this order: P1, P2, P3 Preemptive scheduling Time quantum : 4 ms Gantt chart P1 uses a full time quantum; P2, P3 use only a part of a quantum P1 waits 0+6=6; P2 waits 4; P3 waits 7 Average waiting time: (6+4+7)/3=5.66 ms PIDBurst P124 P23 P33 P1P2P3P1
9
Process Scheduling Simulator
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.