Please I need the correct way to convert Logical (Virtual) Address to Physical Address , i have the following Question :
Given the following Page Table :
Knowing that the virtual pages and physical frame are 1 k Bytes, what is the memory address corresponding to each of the following virtual addresses encoded in hexadecimal: 142A and 0AF1?
i solved it like this , but i don't know if it is correct :
142A (hex)=5162(decimal)
5162/1024=5 (page number ) <----> Frame 1 in page table
5162mod1024=42 (Offset)
so the physical address corresponding to 142A = 1(physical)+42 (offset) or (1*1024+42)
so is that correct ?!
Kind regards
1 Answer
1Kbytes = 1024 bytes. 102410 = 040016
page 0 = 000016, page 1 = 040016, page 2 = 080016, page 3 = 0C0016, page 4 = 100016, page 5 = 140016
- So, 142A16 is in page 5 ...
Logical page 5 points to physical page 1. Each page is 040016 bytes. Physical page 1 starts at 040016 (page 0 would start at 000016).
142A16 is 2A16 bytes past the start of page 5 at 140016 ...
so you add 2A16 to the starting address of physical page 1 which is 040016. So logical address 142A16 really is physical address 042A16.
Anything 140016 to 17FF16 logically corresponds to 040016 to 07FF16 physically, etc.
This is the type of table you could make to help you. All based on multiples of 040016 since that is the page size.
Logical Page Number Logical Page Address -> Physical Page Number Physical Page Address 0 0x0000 - 0x03FF 4 0x1000 - 0x13FF 1 0x0400 - 0x07FF 6 0x1800 - 0x1BFF 2 0x0800 - 0x0BFF 8 0x2000 - 0x03FF 3 0x0C00 - 0x0FFF 9 0x2400 - 0x27FF 4 0x1000 - 0x13FF 12 0x3000 - 0x33FF 5 0x1400 - 0x17FF 1 0x0400 - 0x07FF 1