You are on page 1of 3

Assignment No: 02

CS604
Student ID: bc200407783
Question No: 01
Suppose a system has resource type C with 16 instances and 5 processes and the current
system state is shown in the following table.

Process Max Need Allocated


P0 11 4
P1 6 3
P2 13 4
P3 15 3
P4 7 2

Calculate the Need for each resource by using the need formula and draw the Need Matrix.
Solution:

Need = Max Need – Allocated

Process Max Need Allocated Need


P0 11 4 7
P1 6 3 3
P2 13 4 9
P3 15 3 12
P4 7 2 5

Process: P0 P1 P2 P3 P4
C: 7 3 9 12 5

Question No: 02
Assume a logical address space of 64 pages of 2048 words, each mapped into a physical
memory of 32 frames. You are required to calculate the following parameters related to
paging.
No. of bits needed for p = ? bits
No. of bits needed for f = ? bits
No. of bits needed for d = ? bits
Logical address size = ? bits
Physical address size = ? bits

Solution:
No. of bits needed for p (page number):
Since we have 64 pages, we need enough bits to represent them using 6 bits (26 = 64)
Therefore, No. of bits needed for p = 6 bits.

No. of bits needed for f (frame number):


Similarly, since we have 32 frames, the number of bits needed for f can be calculated using
the formula: (25 = 32).
Therefore, No. of bits needed for f = 5 bits.

No. of bits needed for d (offset within a page):


Each page has 2048 words, which requires 11 bits to represent (211 = 2048).
Therefore, No. of bits needed for d = 11 bits.

Logical address size:


The logical address is composed of the page number (p) and the offset within the page (d).
Adding the bits needed for p and d, we can calculate the logical address size.
Therefore, Logical address size = No. of bits needed for p + No. of bits needed for d = 6
bits + 11 bits = 17 bits.

Physical address size:


The physical address is composed of the frame number (f) and the offset within the frame (d).
Adding the bits needed for f and d, we can calculate the physical address size.
Therefore, Physical address size = No. of bits needed for f + No. of bits needed for d = 5
bits + 11 bits = 16 bits.

Parameters related to paging are as follows:


No. of bits needed for p = 6 bits
No. of bits needed for f = 5 bits
No. of bits needed for d = 11 bits
Logical address size = 17 bits
Physical address size = 16 bits

Question No: 03

The performance measure in paging is the effective memory access time. With part of the
page table in the TLB and the rest in the main memory. In the context of paging, you are
required to calculate the Teffective by considering the following factors.
Tmem = 200 nsec

TTLB = 20 nsec

Hit ratio = 90%

Calculate the Effective Memory Access Time (Teffective) by using the formula. Show each
step of the calculation.
Solution:
Miss ratio (MR)= 1- HR = 1 – 0.9 = 0.1
Substituting the value into formula
Teffective = HR (TTLB + Tmem) + MR (TTLB + 2Tmem) nanoseconds
= 0.9(20+200) + 0.1(20+2*200) nanoseconds
= .9(220) + 0.1(20+400) nanoseconds
= 0.9(220) + 0.1(420) nanoseconds
= 198+42 nanoseconds
= 240 nanoseconds

You might also like