Documente Academic
Documente Profesional
Documente Cultură
PROCESS
MANAGEMENT
It is divided into three parts, the code region, the data region,
and the stack region. The code region contains the program
code that is being executed, the data region contains the data
and variables used by the process, and the stack region
contains the last-in, first-out stack of the process.
• So in multiprogramming/multitasking, the
operating system interleaves the execution of
several processes to maximize the utilization of the
CPU.
Process
.
.
the process is
using the CPU to • The execution of a
. execute machine
instructions
process will start first
inc A
load B CPU
with a CPU burst,
add A, B Burst followed by an I/O
copy C, B burst, and then
write to disk
{wait for I/O completion} I/O Burst followed by another
the process is
CPU burst, etc.
store C waiting for its I/O
shift A CPU
operation (writing
Burst
sub A, B
send to printer
to the disk) to finish
• This continues until a
{wait for I/O completion} I/O Burst final CPU burst
signifying process
.
.
termination is
. encountered.
blocked
blocked
blocked
blocked
blocked
blocked
blocked
• Process Descriptors
3. Suspending a Process
4. Resuming a Process
Resuming a process
means that a
suspended process is
brought back into
main memory in
order for it to resume
execution.
Time
Process 1
CPU Burst I/O Burst . . .
Since Process 1
started an I/O
operation, the OS
will now save its
execution context
in its PCB
Process 2
CPU Burst . . .
Context Switch Time
• As requests for
program execution
from the user or users
come in, programs that
were requested to be
executed will be loaded Job Queue
• The operating
system must now
perform job
scheduling.
Job Queue
Throughput may be
measured in units such as
number of processes
completed per minute or
number of instructions
executed per second.
0 8
A B
0 8 12
A B C
0 8 12 17
A B C D
0 8 12 17 20
A B C D E
0 8 12 17 20 22
And since CPU-bound processes have long CPU burst times, the
I/O-bound processes will have to wait a relatively long period of
time in the ready queue.
• In cases where there are two or more processes with same CPU
burst time, the FCFS algorithm may serve as the tie-breaker. In
other words, the process that entered the queue first is selected
by the CPU scheduler.
0 8
A D
0 8 11
Process Arrival CPU At t = 11, the processes inside the ready queue
ID Time Burst are B, C, and E, in that order.
A 0 8
B 3 4 So the CPU scheduler will select process E
(with a CPU burst of 2) to execute next.
C 4 5
D 6 3 It will start executing at t = 11 and will end at
time t = 13.
E 10 2
The Gantt chart will now be:
A D E
0 8 11 13
A D E B
0 8 11 13 17
A D E B C
0 8 11 13 17 22
• Another disadvantage
is that if there is a
steady stream of
incoming I/O-bound
processes.
A B
0 3
A B
0 3 7
A B D
0 3 7
A B D
0 3 7 10
A B D E
0 3 7 10 12
Process Arrival CPU • At t = 12, the processes inside the ready queue
ID Time Burst are A (CPU Burst of 5) and C (CPU Burst of 5) in
that order.
A 0 5
B 3 0 Both have the same CPU burst times. Since
C 4 5 process A is ahead of process C in the queue,
the CPU scheduler will select process A to
D 6 0 execute next. It will start executing at t = 12
E 10 0 and will end at t = 17.
A B D E A
0 3 7 10 12 17
A B D E A C
0 3 7 10 12 17 22
0 3
Process Arrival CPU • At t = 3, the processes inside the ready queue are B
(CPU Burst of 4) and A (CPU burst of 5) in that order.
ID Time Burst
A 0 5 So the CPU scheduler will select process B to execute
next. It will start executing at t = 3.
B 3 4
C 4 5 At t = 4, process C arrives at the ready queue.
A B
0 3 6
A B A
0 3 6 9
Process Arrival CPU • At t = 9, the processes inside the ready queue are C
(CPU burst of 5), D (CPU burst of 3), B (CPU burst of 1)
ID Time Burst and A (CPU burst of 2) in that order.
A 0 2
So the CPU scheduler will select process C to execute
B 3 1 next. It will start executing at t = 9.
C 4 5
At t = 10, process E arrives at the ready queue.
D 6 3
At t = 12, C has consumed its first time slice so it will
E 10 2 stop executing and go back to the ready queue.
A B A C
0 3 6 9 12
Process Arrival CPU • At t = 12, the processes inside the ready queue are D
ID Time Burst (CPU burst of 3), B (CPU burst of 1), A (CPU burst of 2),
E (CPU burst of 2), and C (CPU burst of 2), in that order.
A 0 2
So the CPU scheduler will select process D to execute
B 3 1 next. It will start executing at t = 12 and will terminate
at t = 15.
C 4 2
D 6 3 Take note that process D will terminate at the exact
time its time slice will expire. Therefore, process D will
E 10 2 no longer go back to the ready queue.
A B A C D
0 3 6 9 12 15
Process Arrival CPU • At t = 15, the processes inside the ready queue are B
ID Time Burst (CPU burst of 1), A (CPU burst of 2), E (CPU burst of 2),
and C (CPU burst of 2), in that order.
A 0 2
B 3 1 So the CPU scheduler will select process B to execute
next. It will start executing at t = 15 and will terminate
C 4 2 at t = 16.
D 6 0 Take note that process B will terminate even before it
E 10 2 has consumed its last time slice.
A B A C D B
0 3 6 9 12 15 16
A B A C D B A
0 3 6 9 12 15 16 18
A B A C D B A E
0 3 6 9 12 15 16 18 20
A B A C D B A E C
0 3 6 9 12 15 16 18 20 22
If the time slice is too small, there will be too many context
switches.
0 8
A C
0 8 13
A C D
0 8 13 16
A C D E
0 8 13 16 18
A C D E B
0 8 13 16 18 22
A B
0 3
A B C
0 3 4 9
A B C D
0 3 4 9
A B C D
0 3 4 9 12
A B C D E B A
0 3 4 9 12 14 17 22
Q1
Processes that finish
executing or request
• Queue Q0 has the highest priority
for an I/O operation
within the given time
while Qn has the lowest.
slice leave the
FCFS (time slice = 20 ms)
queuing network
• Q0 up to Qn-1 follow the FCFS
Processes that do not finish executing within
the given time slice move to the next lower-
algorithm. However, a time quantum
priority queue is assigned (take note that higher
Processes that finish
priority queues have a smaller time
Q2 executing or request
for an I/O operation
quantum).
within the given time
slice leave the
FCFS (time slice = 30 ms)
queuing network
• If a process does not finish executing
within the given time quantum of a
. queue, it is moved to the next lower-
. priority queue.
.
Qn
Processes that finish • The lowest-priority queue follows the
executing or request
for an I/O operation RR scheduling algorithm.
within the given time
slice leave the
RR
queuing network
Qn
Processes that finish
executing or request
If not, it is again moved to a
for an I/O operation
within the given time
lower-priority queue (Q2).
slice leave the
RR
queuing network