0% found this document useful (0 votes)
28 views2 pages

Unix 5

Uploaded by

rambabu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Unix 5

Uploaded by

rambabu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

• Implementation :

This strategy can be implemented by using sorted FIFO queue. All processes in a
queue are sorted based on their priority with highest priority process at front
end. When CPU becomes free, a process from the first position in a queue is
selected to run.
• Example :
Consider the following set of four processes. Their arrival time, total time
required completing the execution and priorities are given in following table.
Consider all time values in millisecond and small values for priority means higher
priority of a process.
Process Arrival Time (T0) Time required for completion ( ∆T) Priority
P0 0 10 5
P1 1 6 4
P2 3 2 2
P3 5 4 0
Here, process priorities are in this order: P3 > P2 > P1 > P0.
• Gantt Chart :

0 10 14 16 22
• Initially only process P0 is present and it is allowed to run. But, when P0
completes, all other processes are present. So, process with highest priority P3 is
selected and allowed to run till
it completes. This procedure is repeated till all processes complete their
execution.
• Statistics :
Process Arrival time (T0) Completion Time (∆T) Finish Time (T1)
Turnaround Time (TAT=T1-T0) Waiting Time (TAT-∆T)
P0 0 10 10 10 0
P1 1 6 22 21 15
P2 3 2 16 13 11
P3 5 4 14 9 5

Average Turnaround Time: (10+21+13+9) / 4 = 53 / 4 = 13.25 ms

Average Waiting Time: (0+15+11+5) / 4 = 31 / 4 = 7.75 ms


• Advantages:
 Priority is considered. Critical processes can get even better response time.
• Disadvantages:
 Starvation is possible for low priority processes. It can be overcome by
using technique called ‘Aging’.
 Aging: gradually increases the priority of processes that wait in the system
for a
long time.

Preemptive Priority Scheduling:


• Selection criteria :
The process, that has highest priority, is served first.
• Decision Mode:
Preemptive: When a new process arrives, its priority is compared with current
process priority. If the new job has higher priority than the current, the current
process is suspended and new job is started.
• Implementation :
This strategy can be implemented by using sorted FIFO queue. All processes in a
queue are sorted based on priority with highest priority process at front end. When
CPU becomes free, a process from the first position in a queue is selected to run.
• Example :
Consider the following set of four processes. Their arrival time, time required
completing the execution and priorities are given in following table. Consider all
time values in milliseconds and small value of priority means higher priority of
the process.

Process Arrival Time (T0) Time required for completion ( ∆T)


Priority
P0 0 10 5
P1 1 6 4
P2 3 2 2
P3 5 4 0

Here process priorities are in this order: P3>P2>P1>P0

• Gantt chart:

0 1 3 5 9 13 22
• Initially only process P0 is present and it is allowed to run. But when P1
comes, it has higher
priority. So, P0 is preempted and P1 is allowed to run. This process is repeated
till all processes complete their execution.

• Statistics:
Process Arrival time (T0) Completion Time (∆T) Finish Time (T1)
Turnaround Time (TAT=T1-T0) Waiting Time (TAT-∆T)
P0 0 10 22 22 12
P1 1 6 13 12 6
P2 3 2 5 2 0
P3 5 4 9 4 0

Average Turnaround Time: (22+12+2+4) / 4 = 40 / 4 = 10 ms


Average Waiting Time: (12+6+0+0) / 4 = 18 / 4 = 4.5 ms

• Advantages:
 Priority is considered. Critical processes can get even better response time.
• Disadvantages:
 Starvation is possible for low priority processes. It can be overcome by
using technique called ‘Aging’.
 Aging: gradually increases the priority of processes that wait in the system
for a long time.
 Context switch overhead is there.

You might also like