Os Past Papers' Solutions 2018
Os Past Papers' Solutions 2018
YEAR 2018
Q # 5:
Determine the system state for the following resource state by using Banker’s
algorithm.
Need Matrix:
Process Need (Max-Allocation)
A B C D
P0 3 0 6 2
P1 2 3 2 1
P2 0 1 0 0
P3 0 0 0 4
P4 6 0 7 0
P5 0 0 5 5
For Safe Sequence, select a process such that Need of the process < Available
resources.
Current Available Resources= (3,1,8,1)
1st Iteration:
Need (Process P2) = (0,1,0,0) < (3,1,8,1) Available resources
Process P2 completes and returns allocated resources, so
Current Available Resources = (3,1,8,1)
+ Resources Allocated to P2 = (0,1,0,1)
=Current Available Resources= (3, 2, 8, 2)
2nd Iteration:
Need (Process P0) = (3,0,6,2) < (3,2,8,2) Available resources
Process P0 completes and returns allocated resources, so
Current Available Resources = (3, 2, 8, 2)
+ Resources Allocated to P0 = (2, 1, 0, 1)
=Current Available Resources= (5, 3, 8, 3)
3rd Iteration:
Need (Process P1) = (2,3,2,1) < (5,3,8,3) Available resources
Process P1 completes and returns allocated resources, so
Current Available Resources = (5, 3, 8, 3)
+ Resources Allocated to P1 = (2, 5, 1, 1)
=Current Available Resources= (7, 8, 9, 4))
4th Iteration:
Need (Process P3) = (0,0,0,4) < (7,8,9,4) Available resources
Process P3 completes and returns allocated resources, so
Current Available Resources = (7, 8, 9, 4)
+ Resources Allocated to P3 = (0, 2, 2, 1)
=Current Available Resources= (7, 10, 11, 5)
5th Iteration:
Need (Process P5) = (0,0,5,5) < (7,10,11,5) Available resources
Process P3 completes and returns allocated resources, so
Current Available Resources = (7, 10, 11, 5)
+ Resources Allocated to P5 = (0, 1, 2, 2)
=Current Available Resources= (7, 11, 13, 7)
6th Iteration:
Need (Process P4) = (6,0,7,0) < (7,11,13,7) Available resources
Process P3 completes and returns allocated resources, so
Current Available Resources = (7, 11, 13, 7)
+ Resources Allocated to P4 = (3, 1, 1, 0)
=Current Available Resources= (10, 12, 14, 7)
so now
Current Available Resources(10, 12, 14, 7)=Total available recourses: (10, 12, 14, 7)
Safe sequence: P2->P0->P1->P3->P5->P4
Q#6:
Consider a computer system with a 24-bit logical address space (here its written
wrong, it should be 24-bit logical address) and 2 KB page size.
Suppose that the maximum physical memory size is 64 MB, and the system is byte-
addressable.
Let paging be implemented on this system. Give answers to the following questions:’
1. How many bits for p and d are there is logical address?
2. How many pages are there in the process?
3. How many frames are there in the memory?
4. What is the size of page table if one entry is of 4 bytes?
5. How many levels of paging will be required for the above scenario?
Solution:
Logical address space= 24-bits, which is 224
224=4 MB (220= 1 MB, 24=16), so the logical address space is 16 MB.
Physical Memory = 64 MB
=220 * 26
=226
Now recall m and n bits, where 2m is the logical address space and 2n is the page or
frame size.
Here logical address space is 224 and page/frame size is 211
1. No of bits for p and d:
So, bits required to address a page number are p = m-n
= 24 – 11
= 13 bits
And bits required to address page displacement d = n bits
= 11 bits
3. No of frames in memory:
Physical memory: 226
Page/Frame size: 211
No of frames = 226 / 211 = 215
215 = 32K
OR
64 MB / 2 KB = 32K
4. Size of page table if page size is 4B?
No of pages = 213
Each page table entry takes = 4B = 22
Page Table Size = 213 * 22 (OR 213 * 4)
=215
= 32 KB
So, the two levels page address will be: 4 Bit – 9 Bit – 11 Bit