National University of Science and Technology
National University of Science and Technology
TECHNOLOGY
5.
Deadlock Starvation
- deadlock is a situation where a -starvation is a situation where a
number of processes cannot proceed signal process is never given a
without a resource that another resource or event that it requires to
holds, but at the same time cannot proceed, this includes CPU time.
release any resources that it is
currently holding
-Is also known as circular wait -Is also known as lived lock
-No process progresses -high priority progresses only while
low priority isn’t allowed.
-Arises due to mutual exclusion, hold -Arise due to uncontrolled
and wait, no pre-emption and management of resources.
circular wait.
-Are prevented by disallowing the Prevented using aging where the
above conditions from occurring and priority of a process increases with
allow pre-emption. increase in waiting time.
11. Both WINDOWS and UNIX boost the priority of I/O-bound processes.
- This is to ensure any waiting on I/O is performed in parallel with other
processes.
-To ensure that CPU-bound processes are not starved of CPU by I/O bound
processes the priority of those tasks are gradually increased to ensure they are
given a chance to run.
12.
Process Burst time(Ms)
P1 10
P2 29
P3 3
P4 7
P5 12
FIFO
Gantt chat
P1 P2 P3 P4 P5
0 10 39 42
49 61
Average waiting time= individual waiting time for the above processes/
number of processes.
= (0+10+39+42+49+61)/5
= 40.2ms
Non-pre-emptive (Shortest Job First)
Gantt chat
P1 P3 P4 P5 P2
0 10 13 20
32 61
Average waiting time= individual waiting time for the above processes/
number of processes.
= (0+10+13+20+32+61)/5
= 27.2ms
Round Robin
P1 P2 P3 P4 P5 P2 P5 P2
0 10 20 23 30 40 50
52 61
Average waiting time= individual waiting time for the above processes/
number of processes.
= (0+(10+20+2) +20+23+40)/5
= 23ms
The round robin scheduling algorithm gives the minimum average time
which means that it has a fast respond at the same time being fair as each
round robin cycle, every process is given a fixed time to execute. No
process is left behind which can allow the elimination of starvation.
13.
Process Allocation Claim matrix Available Need Matrix
Matrix matrix
P1 2 2 3 3 6 8 2 3 0 1 4 5
P2 2 0 3 4 3 3 2 3 0 2 3 0
P3 1 2 4 3 4 4 4 3 3 2 2 0
P1 2 2 3 3 6 8 5 5 7 1 4 5
7 7 10
-Therefore, there are 7-page faults and three-page hits that have occurred.
b. Second Chance (FIFO)
R R R R R R R R R R
0 1 0 1 0 1 0 1 1 1 0 1 0 2 1 2 0 2 1 2
0 2 0 2 0 2 0 2 0 5 0 5 0 5 0 5 0 5
0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3
0 4 0 4 0 4 0 4 0 4 0 1 0 1
Page Page Page Page Page Page Page Page Page Pag
fault fault fault fault hit fault fault hit fault hit
- Therefore, there are 7-page faults and three-page hits that have occurred
c. Least Recently Used
1 1 1 1 1 1 1 1 1 1
2 2 2 2 5 5 5 5 5
3 3 3 3 2 2 2 2
4 4 4 4 3 3 3
Page Page Page Page Page Page Page Page Page Page
fault fault fault fault hit fault fault fault hit hit
Therefore, there are 7-page faults and three-page hits that have occurred.
15 a. FIFO
200
180
160
140
120
100
80
60
40
20
0
Category Category Category Category
1 2 3 4
Series 1
180
160
140
120
100
80
60
40
20
0
Category Category Category Category
1 2 3 4
Series 1
180
160
140
120
100
80
60
40
20
0
Category Category Category Category
1 2 3 4
Series 1
d. C-SCAN
250
200
150
100
50
0
CategoryCategory
1 Category
2 Category
3 4
Series 1
200
180
160
140
120
100
80
60
40
20
0
Category Category Category Category
1 2 3 4