Operating System
Operating System
PROCESS CONCEPT
.
.
.
load
store
add CPU Burst
copy
read from file
{wait for I/O} I/O Burst
store
increment index CPU Burst
write from file
{wait for I/O} I/O Burst
load
store
add CPU Burst
copy
read from file
{wait for I/O} I/O Burst
.
.
.
interrupt
ready running
waiting
process
pointer
state
process number
program counter
registers
memory limits
list of open files
.
.
.
interrupt or system
executing
call
Examples:
thread
Single-threaded Multithreaded
Process Process
Example:
process P0
start idle; idle; idle; stop
input input input
process P1
start idle; idle; idle; stop
input input input
process P0
start idle; idle; idle; stop
input input input
process P1
start idle; idle; idle; stop
input input input
Example:
ready head
queue tail registers registers
. .
. .
. .
mag head
tape tail
PCB5
head
disk 1
tail registers
.
.
.
time slice
expired
child
fork a child
executes
SCHEDULING ALGORITHMS
Example 1:
Process Execution
Name Time
A 24
B 3
C 3
A B C
0 24 27 30
WT for A = 0-0 = 0
WT for B = 24 - 0 = 24
WT for C = 27 - 0 = 27
C B A
0 3 6 30
WT for A = 6-0 = 6
WT for B = 3-0 = 3
WT for C = 0-0 = 0
A B C D E
0 6 8 12 13 16
WT for A = 0-0 = 0
WT for B = 6-1 = 5
WT for C = 8-2 = 6
WT for D = 12 - 3 = 9
WT for E = 13 - 4 = 9
A D B E C
0 6 7 9 12 16
WT for A = 0-0 = 0
WT for B = 7-1 = 6
WT for C = 12 - 2 = 10
WT for D = 6-3 = 3
WT for E = 9-4 = 5
A B D E C A
0 1 3 4 7 11 16
WT for A = (0 - 0) + (11 - 1) = 10
WT for B = 1-1 = 0
WT for C = 7-2 = 5
WT for D = 3-3 = 0
WT for E = 4-4 = 0
p = 1/
The larger the CPU burst, the lower the priority, and
vice versa.
Example:
A C B E D
0 6 10 12 15 16
WT for A = 0-0 = 0
WT for B = 10 - 1 = 9
WT for C = 6-2 = 4
WT for D = 15 - 3 = 12
WT for E = 12 - 4 = 8
A B C B A E D
0 1 2 6 7 12 15 16
WT for A = (0 - 0) + (7 - 1) = 6
WT for B = (1 - 1) + (6 - 2) = 4
WT for C = 2-2 = 0
WT for D = 15 - 3 = 12
WT for E = 12 - 4 = 8
Example:
A B C D E A C E A
0 2 4 6 7 9 11 13 14 16
WT for A = (0 - 0) +
(9 - 2) +
(14 - 11) = 10
WT for B = 2-1 = 1
WT for C = (4 - 2) +
(11 - 6) = 7
WT for D = 6-3 = 3
WT for E = (7 - 4) +
(13 - 9) = 7
Example:
higher priority
system processes
interactive processes
batch processes
student processes
lower priority
quantum = 8
quantum = 16
FCFS