0% found this document useful (0 votes)
132 views4 pages

Os Past Papers' Solutions 2018

This document provides solutions to past paper questions on Banker's algorithm and paging. For question 5, it determines the system state and safe sequence of processes for a given resource allocation using Banker's algorithm. For question 6, it calculates: 1) the number of bits for the page number and offset given a 24-bit logical address space and 2KB page size, 2) the number of pages and frames, 3) the size of the page table, and 4) that 2 levels of paging are required.

Uploaded by

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

Os Past Papers' Solutions 2018

This document provides solutions to past paper questions on Banker's algorithm and paging. For question 5, it determines the system state and safe sequence of processes for a given resource allocation using Banker's algorithm. For question 6, it calculates: 1) the number of bits for the page number and offset given a 24-bit logical address space and 2KB page size, 2) the number of pages and frames, 3) the size of the page table, and 4) that 2 levels of paging are required.

Uploaded by

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

PAST PAPERS’ SOLUTIONS

YEAR 2018

Q # 5:
Determine the system state for the following resource state by using Banker’s
algorithm.

Process Allocation Max Available


A B C D A B C D A B C D
P0 2 1 0 1 5 1 6 3 3 1 8 1
P1 2 5 1 1 4 8 3 2
P2 0 1 0 1 0 2 0 1
P3 0 2 2 1 0 2 2 5
P4 3 1 1 0 9 1 8 0
P5 0 1 2 2 0 1 7 7

Total Available Resources: Available + Allocated


= (3,1,8,1) + (7,11,6,6)
= (10, 12, 14, 7)

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.

Page size= 2 KB, which is (210 * 21)


So the page size is = 211

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

2. No of pages in the Process:


The logical address space = 16 MB (224)
Page size = 2 KB (211)
So pages in process = 224 / 211 = 213
213 = 8k
OR
16 MB/ 2 KB = 8K
these are no of entries in page table as well

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

5. How many levels of paging?


The Virtual address will be 24 bit long, with 11 bits for offset, so 24-11 = 13 bits will be
used as page entries.
Page size is 211
Page table entry takes 4 bytes, 22
So 211 / 22 = 29
No of pages in process = 213
So the number of levels will be 13 / 9= 2 levels (rounded of 1.444)
OR

No of entries in page table * Size of page table entry


213 * 22 = 215, as we have 13 bits for page numbers, this will not be sufficient.

To create more levels:

No of page table in second last level = 215 / 211 = 24

So, the two levels page address will be: 4 Bit – 9 Bit – 11 Bit

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy