You are on page 1of 3

Operating System (CS604) Total marks = 20

Fall 2022 Deadline Date

Assignment # 02 23/01/2023

Student Name:Sheroz khan


Student Id:

OBJECTIVE
The objective of this assignment is to provide hands-on experience of:
 Resource Allocation Graph
 Deadlock Avoidance
 Paging, Logical and Physical Address

Question No. 1 10
Marks

Draw the Resource Allocation Graph from given process states information of a system and
identify the processes if any cycle is created in the graph.

P = P1, P2, P3, P4, P5


R = R1, R2, R3
E = { P1 → R1, P1 → R2, P2 → R1, P3 → R3, P4→R3, P5→ R3, R1 → P4, R2 → P2,
R2 → P5, R3→P2 }

Resource Instances
 One instance of resource type R1
 Two instances of resource type R2
 One instance of resource type R3
Question No. 02 05
Marks

Suppose a system has resource type A with 18 instances and 5 processes and the current
system state is shown in the following table.

Process Max Need Allocated


P0 12 5
P1 6 4
P2 14 4
P3 16 3
P4 8 2

Calculate the Need of each resource by using the need formula and draw the Need Matrix.
Solution :
The need matrix is a table that represents the maximum resources that a process can
still request to complete its execution, given the current system state. It is calculated by
subtracting the allocated resources from the maximum resources required by each
process.

To calculate the need of each resource, we can use the following

formula: Need = Max Need - Allocated

Given the current system state, the need matrix for each process can be
calculated as follows:

Process Max Need Allocated Need of each


resource
P0 12 5 7
P1 6 4 2
P2 14 4 10
P3 16 3 13
P4 8 2 6

Question No. 03 05
Marks
Assume a Logical Address Space of 64 pages of 1024 words, each mapped into a physical
memory of 32 frames. How you can calculate the various parameters related to paging.

No. of bits needed for p = ?


No. of bits neede for f = ?
No. of bits needed for d =?
Logical address size (bits) = ?
Physical address size (bits) = ?
Solution :
No. of bits needed for p:
To calculate the number of bits needed for the page number, we need to determine how many
unique pages there are in the logical address space.
In this case, there are 64 pages, so we need log2 (64) = 6 bits to denoted the page number.
No. of bits needed for f: To calculate the number of bits needed for the frame number, we need
to determine how many unique frames there are in the physical memory.
In this case, there are 32 frames, so we need log2 (32) = 5 bits to represent the frame
number.
No. of bits needed for d: To calculate the number of bits needed for the word offset, we need to
determine how much unique word there are in a page.
In this case, there are 1024 words in a page, so we need log2 (1024) = 10 bits to represent
the word offset.
Logical address size (bits) = p + d = 6 bits + 10 bits = 16 bits
Physical address size (bits) = f + d = 5 bits + 10 bits = 15 bits

You might also like