Assignment II Menu

Question 1

Part a          Part b          Part c
Question 2
Part a        Part b        Part c        Part d        Part e
1. There is a total of 11 units of resource and the system is currently in the following state
a . Table of given system state:
 
Process
Max
Allocation
Still Need
P0
6
3
3
P1
5
3
2
P2
7
1
6
P3
8
2
6
 
The following table step by step shows that the given system state is a safe state or not. 

First, take total of units of resource substract for total of allocations we have available number.

From the available number and Still Need number, we decide which process will be done first. 

After one process is done, it released the allocation amount that it hold before.  Thus, the number of available will be increased each time one process is finished. 

And then do the same for the rest processes until the last one if it is possible.


-*- Checking step by step table:
 

Total resource
Total allocations
Available
Process 
is done
Time
11
9
(at original)
2
(at original)
P1
T1
 
6
(9 - 3 finished 
P1's allocations)

(2 + 3 allocations released from P1)
P1
T2
 
3
(6 - 3 finished 
P0's allocations)
8
(5 + 3 allocations released from P0)
P2
T3
 
2
(3 - 1 finished 
P2's allocation)
9
(8 + 1 allocation released from P2)
P3
T4
 
0
(2 - 2 finished P3's  allocations)
11
(9 + 2 allocations released from P3)
   

Therefore, the complete safe sequence of jobs is:

P1 -----> P0 -----> P2 -----> P3

Back to Menu

b . Table of given system state:
 

Process
Max
Allocation
Still Need
P0
6
3
3
P1
5
4
1
P2
7
1
6
P3
8
2
6

        -*- Checking step by step table:
 

Total 
Resource
Total Allocations
Available
Process 
is done
Time
11
10
(At original)
1
(At original)
P1
T1
 
6
(10 - 4 finished 
P1's allocations)
5
(1 + 4 allocations released from P1)
P0
T2
 
3
(6 - 3 finished 
P0's allocations)
8
(5 + 3 allocations released from P0)
P2
T3
 
2
(3 - 1 finished 
P2's allocation)
9
(8 + 1 allocation released from P2)
P3
T4
 
0
(2 - 2 finished P3's  allocations)
11
(9 + 2 allocations released from P3)
   

Therefore, the complete safe sequence of jobs is:

P0 -----> P1 -----> P2 -----> P3

Back to Menu

c . Table of given state:
 

Process
Max
Allocation
Still Need
P0
6
3
3
P1
5
3
2
P2
7
2
5
P3
8
2
6
 
We have the formula:

                    available = Total Resource - Total allocations
                                    =        11           -            10
                                    =    1

From here, we see that the number of available is not big enough for running any process in the given system state.  Therefore, a request of 1 unit by P2 shouldn't be granted.
Back to Menu
2. There is a total of 15 units of R1 (resource 1) and 7 units of R2 and the system is in the following state (again call it S0)
a. Table of given system state:
 
Process
Max
Allocation
Still Need
 
R1  | R2
R1  | R2
R1  | R2
P0
4  |  2
2  |  2
2  |  0
P1
5  |  7
4  |  1
1  |  6
P2
4  |  6
3  |  1
1  |  5
P3
6  |  4
3  |  2
3  |  2

-*- Checking step by step table:
 

Total
Resource
Total
Allocations
Available
Process
is done
Time
R1  | R2
R1  | R2
R1  |  R2
R1  |  R2
R1  |  R2
15  |  7
12  |  6
(at original)
3  |  1
(at original)
P0
T1
 
10  |  4
(12 - 2) | (6 - 2)
5  |  3
(3 + 2) | ( 1 + 2)
P3
T2
 
7  |  2
(10 - 3) | (4 - 2)
8  |  5
(5 + 3) | (3 + 2)
P2
T3
 
4  |  1
(7 - 3) | (2 - 1)
11  |  6
(8 + 3) | (5 + 1)
P1
T4
 
0  |  0
(4 - 4) | (1 - 1)
15  |  7
(11 + 4) | (6 + 1)
   

Therefore, the safe sequence of the given jobs is:

P0 -----> P3 ----->  P2 -----> P1

Back to Menu

b . Table of given system state:
 

Process
Max
Allocation
Still Need
 
R1  | R2
R1  | R2
R1  | R2
P0
4  |  2
2  |  2
2  |  0
P1
5  |  7
4  |  1
1  |  6
P2
4  |  6
5  |  1
?  |  5
P3
6  |  4
3  |  2
3  |  2
 
From the table we see that the Allocation number of R1 is greater than its Max number.  Therefore, the given system state cannot be in safe state.  Therefore, a request of (2,0) units by P2 shouldn't be granted.
Back to Menu

c. Table of given system state:
 

Process
Max
Allocation
Still Need
 
R1  | R2
R1  | R2
R1  | R2
P0
4  | 2
2  |  2
2  |  0
P1
5  |  7
4  |  1
1  |  6
P2
4  |  6
3  |  3
1  |  3
P3
6  |  4
3  |  2
3  |  3
 
From this table, we see that the total allocations number of R2 is greater than its total resources number.  Therefore, the given system state cannot be in safe state.  Therefore, a request of (0,2) units by P2 shouldn't be granted.
Back to Menu

d. Table of given system state:
 

Process
Max
Allocation
Still Need
 
R1  | R2
R1  | R2
R1  | R2
P0
4  |  2
2  |  2
2  |  0
P1
5  |  7
4  |  1
1  |  6
P2
4  |  6
3  |  1
1  |  5
P3
6  |  4
5  | 2
1  |  2
 
From the table we see that the availbe number resource for R1 and R2 is (1 | 1).  this available resource is not big enough for and given process run completely.  Therefore, the given system state cannot be in safe state.  Therefore, a request of (2,0) units by P3 shouldn't be granted.
Back to Menu

e. Table of given system state:
 

Process
Max
Allocation
Still Need
 
R1  | R2
R1  | R2
R1  | R2
P0
4  |  2
2  |  2
2  |  0
P1
5  |  7
4  |  1
1  |  6
P2
4  |  6
4  |  2
0  |  4
P3
6  |  4
3  |  2
3  |  2

     -*- Checking step by step table:
 

Total
Resource
Total Allocations
Available
Process
is done
Time
R1  | R2
R1  | R2
R1  | R2
R1  | R2
R1  | R2
15  |  7
13  |  7
(at original)
2  |  0
(at original)
P0
 T1
 
11  |  5
(13 - 2) | (7 - 2)
4  |  2
(2 + 2) | (0 + 2)
P3
 T2
 
8  |  3
(11 - 3) | (5 - 2)
7  |  4
(4 + 3) | (2 + 2)
P2
 T3
 
4  |  1
(8 - 4) | (3 - 2)
11  |  6
(7 + 4) | (4 + 2)
P1
 T4
 
0  |  0
(4 - 4) | (1 - 1)
15  |  7
(11 + 4) | (6 + 1)
   

Therefore, the safe sequence of the given jobs is:

P0 -----> P3 ----->  P2 -----> P1

Back to Menu