0
$\begingroup$

Consider a logical address space of 4096, page size = 1024 physical memory = 8192

$\begin{array} {|c|c|} \hline \text{Page No} & \text{Frame No} \\ \hline 0 &7 \\ \hline 1 &4 \\ \hline 2 &2 \\ \hline 3 &3 \\ \hline \end{array}$
What is the physical address corresponding to logical address 500, 1000, 2000, 3000, and 4000?

Can I know how to solve this step by step?
Only one example would be enough.

$\endgroup$

2 Answers 2

1
$\begingroup$

Since you have not mentioned word size, I am going to assume they are same across all three terms. Your problem boils down to calculating which page number(address range) the logical address lies in, finding offset of that address within the page and adding the offset to the physical address where that page is mapped.

Let's do some base calculation

No. of pages per process = $floor$($logical$ $address$ $space$/$page$ $size$)$ = 4$

No. of frames in physical(main) memory = $floor$($physical$ $memory$ $size$/$page$ $size$)$ = 8$

Consider the logical address $2000$

Page no. which contains 1000 = $floor(2000/1024) = 1$ i.e. address 2000 lies in page no 1.

Offset of 2000 in page no. 1 = $2000mod1024=976$

This offset remains same when a page is mapped to a frame. Now we just need to find out the base address of the frame where page no. 1 lies and add the offset to it.

From your page table, it says page no. 1 is held by frame no. 4. The base address of frame no. 4 = $4*1024=4096$ and goes upto $5119$.

So finally, logical address $2000$ corresponds to physical address $4096+976=5072$

Hope this helps. You can similarly find it for others.

$\endgroup$
5
  • $\begingroup$ Thanks a lot for your answer. I got the steps. But can I know what is the word size that you asked for? The question didn’t provide that. $\endgroup$ May 2, 2022 at 9:29
  • $\begingroup$ word size means the amount of data that the cpu can process at a time. So when you hear a 64 bit cpu, it vaguely means it can process 64 bits i.e. 8 bytes at a time. Reason why I assumed it to be same across all three terms is because if your page size was 1024 bytes and logical address space was 4096 words where 1 word = 2 bytes then the calculation would have to account for that as well. So its always better to have the units mentioned explicitly. This is not an exact example but just to let you know the impact of different units on calculation. $\endgroup$
    – Rinkesh P
    May 2, 2022 at 10:22
  • $\begingroup$ A mapping that changes the word size would make no sense ! $\endgroup$
    – user16034
    May 2, 2022 at 16:43
  • 1
    $\begingroup$ Agreed. But I have come across badly framed questions (which this seemed to me) which play around with numbers because in the end its just math, so just a heads up to OP. $\endgroup$
    – Rinkesh P
    May 2, 2022 at 16:51
  • $\begingroup$ Can you help me on this? cs.stackexchange.com/q/151204/150326 $\endgroup$ May 3, 2022 at 9:11
0
$\begingroup$

Use this correspondence table:

Logical addresses / Physical addresses 
     0-1023           7168-8191
  1024-2047           4096-5119
  2048-3071           2048-3071
  3072-4095           3072-4095
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.