Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process...
-
date post
19-Dec-2015 -
Category
Documents
-
view
215 -
download
0
Transcript of Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process...
![Page 1: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/1.jpg)
Day 25Uniprocessor scheduling
![Page 2: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/2.jpg)
Algorithm: Selection function
Selection function – which process among ready processes to select.
w – time spent in system, waiting and executing, so far
e – time spent in execution, so far s- total service time required by the process
Service time – the time that the process actually runs (includes e)
![Page 3: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/3.jpg)
Algorithm: Decision Mode Non-pre-emptive
Once a process is in the running state, it will continue until it terminates or blocks itself for I/O
Selection function is used only when a process blocks or terminates
Pre-emptive Currently running process may be forced to release the
processor and moved to the Ready state by the operating system
Allows for better service since any one process cannot monopolize the processor for very long
More switching overhead Selection function is used when a process blocks or terminates
or when a new process enters the system or when a time slice expires.
![Page 4: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/4.jpg)
First-Come-First-Served(FCFS/FIFO)
Each process joins the Ready queue When the current process ceases to execute,
the oldest process in the Ready queue is selected non-pre-emptive
A short process may have to wait a very long time before it can execute
![Page 5: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/5.jpg)
FCFS
Arrival time Service Time
P1 0 24
P2 1 3
P3 2 3
Calculate the turn-around time for each process and the average turn-around time.
![Page 6: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/6.jpg)
FCFS
Favors CPU-bound processes I/O processes have to wait until CPU-bound
process completes Inefficient use of processor and I/O devices. Rarely used on its own.
![Page 7: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/7.jpg)
Process Scheduling Example
![Page 8: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/8.jpg)
First-Come-First-Served(FCFS)
0 5 10 15 20
A
B
C
D
E
![Page 9: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/9.jpg)
Shortest Process Next (SPN)
Select the shortest process in the ready queue.
Non-pre-emptive. Reduces the response time for shorter
processes. Less predictable response time for longer
processes. Must estimate the running time for each
process.
![Page 10: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/10.jpg)
Process Scheduling Example
![Page 11: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/11.jpg)
Shortest Process Next (SPN)
0 5 10 15 20
A
B
C
D
E
![Page 12: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/12.jpg)
Shortest Remaining Time(SRT)
Pre-emptive version of SPN. Check when a new process enters the
system and when the current process voluntarily releases the processor.
Better response time as short jobs given immediate preference.
Fewer process switches than RR. Must keep track of elapsed time.
![Page 13: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/13.jpg)
Process Scheduling Example
![Page 14: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/14.jpg)
Shortest Remaining Time(SRT)
0 5 10 15 20
A
B
C
D
E
![Page 15: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/15.jpg)
Round robin
Pre-empt a process using the clock interrupt. A process is allowed to run for a time-slice or
quantum. The next process in the Ready queue is
selected to run following the pre-emption (FCFS).
Prevents large processes from monopolizing the processor.
![Page 16: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/16.jpg)
Round robin
Design issue: length of quantum Short quantum
short processes will finish quickly. lots of process switches
Choose such that typical processes can complete without being interrupted.
![Page 17: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/17.jpg)
Round robin
Unfair to I/O-bound processes as they will typically not use a complete quantum, while CPU-bound processes will.
Use Virtual Round Robin Use an auxiliary queue to hold processes that
have I/O requests serviced. Process in auxiliary queue gets preference over
those in the main ready queue. Process from the auxiliary runs for time remaining
from last time-slice.
![Page 18: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/18.jpg)
![Page 19: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/19.jpg)
Process Scheduling Example
![Page 20: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/20.jpg)
Round-Robin
0 5 10 15 20
A
B
C
D
E
![Page 21: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/21.jpg)
Highest Response Ratio Next (HRRN)
ss w
ratio Response
w – time spent waiting for the processor
s – expected service time
![Page 22: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/22.jpg)
HRRN
Non-pre-emptive Select the process that has the highest
response ratio. Short process (small “s”) given preference. Long process(large “s”) that has been waiting
a long time (large “w”) is given preference. Accounts for age of process.
Must estimate “s”.
![Page 23: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/23.jpg)
Process Scheduling Example
![Page 24: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/24.jpg)
Highest Response Ratio Next (HRRN)
A
B
C
D
E
0 5 10 15 20
![Page 25: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/25.jpg)
Multi-level Feedback (quantum = i)
Pre-emptive (time quantum) Maintain many ready queues of varying priority.
Each queue uses FCFS. A process that is pre-empted is moved to a queue of
lower priority to wait. Thus longer processes are penalized. Don’t have to estimate running time. Note: If there are no processes waiting, don’t pre-
empt the process
![Page 26: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/26.jpg)
![Page 27: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/27.jpg)
Process Scheduling Example
![Page 28: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/28.jpg)
Multi-level Feedback (quantum = i)
0 5 10 15 20
A
B
C
D
E
![Page 29: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/29.jpg)
Multi-level Feedback (quantum = 2i * quantum)
With quantum = i, long processes will have very high turn-around time.
So, a process in queue RQi will be allowed to run for 2i * quantum.
![Page 30: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/30.jpg)
Multi-level Feedback (quantum = 2i * quantum)
![Page 31: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/31.jpg)
Fair-Share Scheduling
Treat multiple processes and threads of a user as a collection.
The performance of the collection of threads is optimized not just that of any one thread or process.
Fair share scheduling ensures that users are given a fair share of the processor time.
![Page 32: Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,](https://reader030.fdocuments.net/reader030/viewer/2022032703/56649d2d5503460f94a03a37/html5/thumbnails/32.jpg)
FSS
Divide user community into groups. Each user process’ priority is based on the
process’ execution time and the execution time of processes within the same group.