问题
I am trying to understand paging and am running into some problems. I've found an example problem that I cannot make sense of, and was hoping that someone could set me in the correct direction:
The theoretical system in question has 64K (2^16) bytes of memory. The page size is 4K bytes (2^12), and the page table has 15 entires. Foreach entry in the page table for a theoretical process X, there is page number, a present/absent bit, and a page frame number.
I understand that the look-up of the physical address uses the page size as the amount devoted to the offset, and the rest of the address space to the page frame number; however, without the address space number, I am confused how I could calculate how many bits are required to represent the physical address on the theoretical system.
To complicate things further, I am not sure how I would represent the virtual address if I am given the maximum address space (say 32K bytes). Given the structure of the page table, I feel like it would simply be the size of the address space. This doesn't feel right too me though.
Any help to clarify how this stuff works would be appreciative. I noticed in my research that you can calculate the number of table entries by performing the size of the address space divided by the page size. I thought that this would answer my question in re: to how many bits would be used to represent the physical address, but then noticed that assumption would be flawed.
Thanks everyone.
MN7
回答1:
I shall try answering this question. Presumably, you would like to know how, from a given address space number, you can derive:
- the bits set aside for looking up the page number in the page table and
- the bits meant for calculating the offset within the identified page.
This is a design decision for the OS and the answer to your question really is determined upfront before you even get down to deciding on the number of bits for page number and offset.
Hope this helps. I am open to better answers.
来源:https://stackoverflow.com/questions/13004285/paging-explanation-required