Professional Documents
Culture Documents
Basic Concepts Scheduling Criteria Scheduling Algorithms
Basic Concepts Scheduling Criteria Scheduling Algorithms
Basic Concepts
Scheduling Criteria
Scheduling Algorithms
6.1
Basic Concepts
Maximum CPU utilization obtained
with multiprogramming.
6.2
CPU Scheduler
The CPU scheduler (short-term scheduler) selects from among the
processes in memory that are ready to execute, and allocates the
CPU to one of them.
6.3
Dispatcher
6.4
Scheduling Criteria
6.5
Optimization Criteria
6.6
Scheduling Algorithms
6.7
CPU
Ready Queue
6.8
Example:
Process
P1
24
P2
P3
P2
24
P3
27
30
6.9
P3
3
P1
6
30
6.10
6.11
Associate with each process the length of its next CPU burst.
Use these lengths to schedule the process with the shortest
time.
Two schemes:
Nonpreemptive once CPU given to the process it
cannot be preempted until completes its CPU burst.
Preemptive if a new process arrives with CPU burst
length less than remaining time of current executing
process, preempt. This scheme is known as the
Shortest-Remaining-Time-First (SRTF).
If two processes have the same length next CPU burst, FCFS
scheduling is used.
6.12
Example: Process
Arrival Time
Burst Time
P1
0.0
P2
2.0
P3
4.0
P4
5.0
SJF (non-preemptive)
P1
0
P3
7
P2
8
P4
12
16
6.13
6.14
Example:
Process
Arrival Time
Burst Time
P1
0.0
P2
2.0
P3
4.0
P4
5.0
P2
2
P3
4
P2
5
P1
P4
7
11
16
6.15
Priority Scheduling
6.16
6.17
Burst Time
10
1
2
1
5
Priority
3
1
3
4
2
Gantt Chart:
P2
0
P5
1
P3
P1
6
16
P4
18
19
6.18
Each process gets a small unit of CPU time (time quantum or time
slice ), usually 10-100 milliseconds. After this time has elapsed,
the process is preempted and added to the end of the ready queue.
That is, after the time slice is expired an interrupt will occur and a
context switch.
Ready Queue
Completion
3
CPU
Preemption
Time Slice
6.19
6.20
10
Burst Time
P1
53
0+(77-20)+(121-97)=81
P2
17
P3
68
37+(97-57)+(134-117)=94
P4
24
57+(117-77)=97
20
P2
20
37
P3
P4
57
P1
77
P3
97 117
P4
P1
P3
P3
6.21
6.22
11
Multilevel Queue
6.23
6.24
12
6.25
6.26
13
Three queues:
Q0 time quantum 8 milliseconds
Q1 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.
6.27
14