1
$\begingroup$

If the page size is 4Kbyte and the physical size of the main memory is 32Kbyte. Now if I consider virtual address of 37064..

The page number is then 37064/4096 = 9

And according to my diagram page 9 is mapped to frame 6

But how do I calculate the offset? According to exercise it should be 200. Thank you

$\endgroup$
1
  • $\begingroup$ Hint: do the exercise in hexadecimal. A 4 kilobyte page is exactly 0x1000 bytes long. $\endgroup$
    – MSalters
    Commented Jan 25, 2021 at 10:59

2 Answers 2

1
$\begingroup$

The page size indicates how much bits represent the offset in the physical frame. In this case you have pages of 4KB that means you need 12 bits because 2^12 = 4096. The offset in the physical frame always starts at the least significant bits. So for your example with

37064 = 0b1001 0000 1100 1000,

0000 1100 1000 = 200 in decimal is the offset in the physical frame. Since you have only one level of page tables, the rest of the bits to the left represent the actual physical page. You should not see it as a division even though it works. So the offset in the page table is 1001 = 9.

$\endgroup$
0
$\begingroup$

The offset is 37064 % 4096 = 200.

% is modulo operator to calculate for remainder of a division.

So to get the offset, the formula is: offset = [virtual address] % [page size].

2 Years late but hopefully it helps someone looking for this in the future.

$\endgroup$
1
  • $\begingroup$ Yep, some day ChatGPT will read it. $\endgroup$
    – user16034
    Commented Feb 10, 2023 at 18:00

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.