Professional Documents
Culture Documents
(A) 9
(B) 9
(C) And (D)
P0 (4 children – P1, P2, P3, P4) Final value 40, 30 [4 threads]
P1 (3 children – P5, P6, P7) Final value 26, 16 [3 threads]
P2 (No children) Final value 35, 17
P3 (1 child – P8) Final value 26, 35 [1 thread]
P4 (No children) Final value 50, 32
P5 (No children) Final value 21, 22
P6 (1 child – P9) Final value 12, 21 [1 thread]
P7 (No children) Final value 36, 18
P8 (No children) Final value 36, 37
P9 (No children) Final value 22, 23
Question #2 [4M + 2M + 4M = 10 Marks]
Assume a memory management module supporting BUDDY system for the placement of
1 MB memory. Allocate the following requests [the requests are coming one after the
other in the same order]. Clearly mention all the requests which you could not allocate.
Request 1: Allocate 65KB Request 7: Allocate 300KB
Request 2: Allocate 10KB Request 8: Allocate 36KB
Request 3: Allocate 80KB Request 9: Allocate 62KB
Request 4: Allocate 130KB Request 10: Release 80KB [Allocated by request 3]
Request 5: Allocate 160KB Request 11: Allocate 150KB
Request 6: Release 130KB [Allocated by request 4]
After finishing all the requests
(1) Draw the final tree representation of the BUDDY system [After Request 11].
(2) Find the total free space available in the system for allocation
(3) Find the total internal fragmentation caused because of all the allocations.
(1) [0-128K] R1, [128K – 144K] R2, [192K – 256K] R8, [384K – 448K] R9, [512K – 768K] R11,
[768K – 1M] R5
(2) 240KB
(3) 301KB
(A) 15, 36
(B) 12, 12, 12, 15
(C) 24, 27
Question #5 [5 Marks]
Assume a main memory having 16 frames. The individual process page tables are given
below. The administrator wanted to change the page table model into inverted page table
model. Construct inverted page table from the given process information
[P0] pid = 20 [P1] pid = 28 [P2] pid = 12 [P3] pid = 31 [P4] pid = 16
Frame# v/i Frame# v/i Frame# v/i Frame# v/i Frame# v/i
3 V 14 V 3 i 2 V 7 V
12 I 5 V 8 v 1 V 12 V
11 V 7 I 15 i 11 I 1 I
5 I 9 I 0 v 10 V 9 V
13 V 15 V 4 v 7 I 6 V
Single table consists of 16 entries. Each entry will have pid and page number in it
Pid Page #
12 3
31 1
31 0
20 0
12 4
28 1
16 4
16 0
12 1
16 3
31 3
20 2
16 1
20 4
28 0
28 4
Question #6 [5 Marks]
Consider the following snapshot at time t. Draw wait for graph. Does the system enter
into deadlock [Yes/No]? Explain.
Process Data Data items the Process Data Data items
items process is items the process
locked waiting for locked is waiting for
P1 X2 X1 P5 X1, X5 X3
P2 X3, X10 X7, X8 P6 X4, X9 X6
P3 X8 X4 P7 X6 X5
P4 X7 X1
Question #7 [4 + 6 = 10 Marks]
Consider the following snap shot of the system of five processes P0 to P4 and 5 resource
types, A, B, C, D and E. The total instances of A, B, C, D and E in the system are 10, 17,
10, 13 and 11 respectively.
Processes Maximum Claim Need
A B C D E A B C D E
P0 9 13 10 7 8 7 11 8 5 8
P1 4 9 7 5 5 3 7 6 3 3
P2 7 13 5 10 10 6 11 4 8 10
P3 1 5 1 3 5 1 3 1 1 3
P4 5 8 5 5 9 3 6 4 5 5
(A) Determine if the system is in the safe state. If yes, give the safe sequence and
other relevant matrices.
(B) If process P0 requests (0, X, Y, Z, 0), then determine the maximum values of X, Y
and Z which can be granted without making the state unsafe.
Answer
ALLOCATION
Process A B C D E
P0 2 2 2 2 0
P1 1 2 1 2 2
P2 1 2 1 2 0
P3 0 2 0 2 2
P4 2 2 1 0 4
AVAILABLE
4 7 5 5 3
Safe sequence P3, P4, P1, P2, P0 (Only one safe sequence possible)
(A) If process P0 requests (0, X, Y, Z, 0), then determine the maximum values of X, Y and Z which
can be granted without making the state unsafe.
X2 Y0 Z1
Question #8 [9 Marks]
Write a monitor for Reader – Writer problem. The monitor should have the following
functions – Writer_Entry, Writer_Exit, Reader_Entry, Reader_Exit. Use minimum
number of condition variables.
Monitor
{
Writer_Entry()
{ if((read_count>0) || (write_count>0)) wrt.wait;
write_count=1;
}
Writer_Exit()
{ if(read>0) rd.signal;
else wrt.signal;
}
Reader_Entry()
{ read++;
if(write_count==1) rd.wait;
read_count++;
rd.signal;
}
Reader_Exit()
{ read - -;
read_count - -;
if(read_count==0) wrt.signal;
}
Initilize()
{ read_count=0; write_count=0; readd=0;
}
}
Question #9 [6 Marks]
If initial value of shared variable x is 0, find the maximum and minimum x value
possible when T1 and T2 are executing concurrently. Write the sequence in which this
occurs.
T1 T2
int i; int i;
for ( i = 0; i < 100; i + + ) for ( i = 0; i < 100; i + + )
{ x = x + 1; { x = x + 1;
x = x – 1; x = x – 1;
x = x + 1; }
}
Initialization: 1M
Thread 1: 4
Thread 2: 2
Thread 3: 4