1/43
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
CPU–I/O Burst Cycle
Basic Concepts
Maximum CPU utilization obtained with multiprogramming
— Process execution consists of a cycle of CPU execution and I/O wait
I/O burst
Basic Concepts
CPU burst followed by —
CPU burst distribution is of main concern
Histogram of CPU-burst Times
—
Large number of short bursts
Small number of longer bursts
CPU scheduler
selects from among the processes in ready queue, and allocates a CPU core to one of them
Queue may be ordered in various ways
1. Switches from running to waiting state
2. Switches from running to ready state
3. Switches from waiting to ready
4. Terminates
CPU scheduling decisions may take place when a process (4)
1 and 4
2 and 3
For situations , there is no choice in terms of scheduling. A new process (if one exists in the ready queue) must be selected for execution.
For situations —, however, there is a choice.
nonpreemptive
preemptive
When scheduling takes place only under circumstances 1 and 4, the scheduling scheme is —
Otherwise, it is—
Nonpreemptive scheduling
Under —, once the CPU has been allocated to a process, the process keeps the CPU until it releases it either by terminating or by switching to the waiting state.
preemptive scheduling algorithms
Virtually all modern operating systems including Windows, MacOS, Linux, and UNIX use
race conditions
Preemptive scheduling can result in — when data are shared among several processes.
Consider the case of two processes that share data. While one process is updating the data, it is preempted so that the second process can run. The second process then tries to read the data, which are in an inconsistent state.
Dispatcher module
— gives control of the CPU to the process selected by the CPU scheduler; this involves:
Switching context
Switching to user mode
Jumping to the proper location in the user program to restart that program
Dispatch latency
time it takes for the dispatcher to stop one process and start another running
CPU utilization
Throughput
Turnaround time
Waiting time
Response time
5 Scheduling Criteria
CPU utilization
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.
Max CPU utilization
Max throughput
Min turnaround time
Min waiting time
Min response time
5 Scheduling Algorithm Optimization Criteria
First- Come, First-Served (FCFS) Scheduling
(0 + 24 + 27)/3 = 17
—
Waiting time for P1 = 0; P2 = 24; P3 = 27
Average waiting time: —
(6 + 0 + 3)/3 = 3
Waiting time for P1 = 6; P2 = 0 ; P3 = 3
Average waiting time: —
Much better than previous case
Convoy effect
— short process behind long process
Consider one CPU-bound and many I/O-bound processes
Shortest-Job-First (SJF) Scheduling
optimal
Associate with each process the length of its next CPU burst
Use these lengths to schedule the process with the shortest time
— gives minimum average waiting time for a given set of processes
shortest-remaining-time-first
Preemptive version called —
How do we determine the length of the next CPU burst?
Could ask the user
Estimate
(9+24+16+3) / 4 =13
(3 + 16 + 9 + 0) / 4 = 7
Average turnaround time(finish - arrival) =
Average waiting time(turnaround - burst) =
shortest predicted next CPU burst
Determining Length of Next CPU Burst
Can only estimate the length which should be similar to the previous one
Then pick process with —
exponential averaging
½
Determining Length of Next CPU Burst
Can be done by using the length of previous CPU bursts, using —
Commonly, α set to —
less weight
Examples of Exponential Averaging
Since both α and (1 - α) are less than or equal to 1, each successor predecessor term has — than its predecessor
Shortest Remaining Time First Scheduling
—
Preemptive version of SJN
Whenever a new process arrives in the ready queue, the decision on which process to schedule next is redone using the SJN algorithm.
Is SRT more “optimal” than SJN in terms of the minimum average waiting time for a given set of processes?
[(10-1)+(1-1)+(17-2)+(5-3)]/4 = 26/4 = 6.5
Example of Shortest-remaining-time-first
Average waiting time =
Round Robin (RR)
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.
FIFO (FCFS)
RR
Round Robin (RR)
Timer interrupts every quantum to schedule next process
Performance
q large ⇒ —
q small ⇒ —
Note that q must be large with respect to context switch, otherwise overhead is too high
response
context switch time
Example of RR with Time Quantum = 4
Typically, higher average turnaround than SJF, but better —
q should be large compared to —
q usually 10 milliseconds to 100 milliseconds,
Context switch < 10 microseconds
Time Quantum and Context Switch Time
process time, quantum, context switches
Turnaround Time Varies With The Time Quantum
80% of CPU bursts should be shorter than q
Priority Scheduling
A priority number (integer) is associated with each process ▪
The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority)
Preemptive
Nonpreemptive
SJF
is priority scheduling where priority is the inverse of predicted next CPU burst time
Starvation
Aging
Problem ≡ — low priority processes may never execute
Solution ≡ — as time progresses increase the priority of the process
8.2
Example of Priority Scheduling
Average waiting time =
Priority Scheduling w/ Round-Robin
Run the process with the highest priority. Processes with the same priority run round-robin
Multilevel Queue
The ready queue consists of multiple queues
Number
Scheduling algorithms
needs service
Scheduling
Multilevel queue scheduler defined by the following parameters (4)
— of queues
— for each queue
Method used to determine which queue a process will enter when that process —
— among the queues