0
$\begingroup$

I am trying to understand the concept of logical to physical addressing.
I am given 72 physical addresses (0-71) with values

A virtual address = 2^(p+w) p = page bits w = word bits

I know the page table is of size 6 indexed 0-5

If a page size is 16 words does that mean that the offset(w)=4, giving me 2^(p+4).

If thats the case how do I determine what the page number (p) if given a logical address of 12? I was thinking it would be 3 because I would need 3 bits to find the index of the page table 0-5, giving me 000 1100, index 0, offset 12. I feel like I might be missing something.

$\endgroup$
0
$\begingroup$

I think you are confused in how logical address is get converted into physical address of main memory. Let's take a walk from basics: logical and physical memory are divided into fixed size pages and frames respectively to remove external fragmentation.

As size of logical memory is generally bigger than physical memory so we can't bring all pages from logical memory into physical memory that's why we require a page table that contains the entry of pair(page no. , frame no.).

Now as always CPU generates a logical address of say 15 bits with 10bits for page size and 5bits for identifying frame no. from page table(5bits means that there can be maximum 2^5 pages), now using those 5 bits cpu index page table and find the frame no. in which the required page is residing say that's of 4 bits(that mean a maximum of 2^4 frames ) then the physical address will be made by replacing 5bits by those 4bits + 10bits in logical address.

Your interpretation in question is correct.

$\endgroup$
  • $\begingroup$ Hello and thank you for the response! So when you say my interpretation is correct you mean that since my page table is size 6 (indexed 0-5) I would have 3 bits to identify the frame number? $\endgroup$ – MangoHabanero Jul 10 '15 at 15:44
  • $\begingroup$ To identify frame number, we require log2(no. of frames) bits that depends on the size of physical memory only, page table is to store page to frame number mapping, number of enteries in page table is equal to number of pages in logical memory, so if there are n pages in logical memory then there will be log2(n) bits for indexing page table. Page table has one to one mapping of pages to frame no. , if page is not present in main memory then entry corresponding to that page no. in page table is empty, that means a page fault. $\endgroup$ – suraj3 Jul 10 '15 at 16:12
  • $\begingroup$ When i say your interpretation is correct that means that at index 0 of page table, frame no. of page 0 is present and 12 is the offset in that page as well as frame as size of page and frame is always same. Hope it clears your doubt, if yes then up vote so that it can be useful for others. $\endgroup$ – suraj3 Jul 10 '15 at 16:16
  • $\begingroup$ Thanks again! I think I have a better understanding then. Since my page table has an index of 6 I will have log2(8) or 3 bits for my page number. $\endgroup$ – MangoHabanero Jul 10 '15 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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