Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So, first lets clarify some things:</p> <ol> <li>In the case of the x86 architecture, it is not the operating system that determines the paging policy, it is the CPU (more specifically it's MMU). How the operating system views the paging system is independent of the the way it is implemented. As a commenter rightly pointed out, there is an OS specific component to paging models. This is subordinate to the hardware's way of doing things.</li> <li>32 bit and 64 bit x86 processors have different paging schemes so you can't really talk about the x86 paging model without also specifying the word size of the processor.</li> </ol> <p>What follows is a massively condensed version of the 32 bit x86 paging model, using the simplest version of it. There are many additional tweaks that are possible and I know that various OS's make use of them. I'm not going into those because I'm not really familiar with the internals of most OS's and because you really shouldn't go into that until you have a grasp on the simpler stuff. If you want the to know all of the wonderful quirks of the x86 paging model, you can go to the Intel docs: <a href="http://www.intel.com/Assets/PDF/manual/325384.pdf">Intel System Programming Guide</a></p> <p>In the simplest paging model, the memory space is divided into 4KB blocks called pages. A contiguous chunk of 1024 of these is mapped to a page table (which is also 4KB in size). For a further level of indirection, All 1024 page tables are mapped to a 4KB page directory and the base of this directory sits in a special register <code>%cr3</code> in the processor. This two level structure is in place because most memory spaces in the OS are <em>sparse</em> which means that most of it is unused. You don't want to keep a bunch of page tables around for memory that isn't touched.</p> <p>When you get a memory address, the most significant 10 bits index into the page directory, which gives you the base of the page table. The next 10 bits index into that page table to give you the base of the physical page (also called the physical frame). Finally, the last 12 bits index into the frame. The MMU does all of this for you, assuming you've set <code>%cr3</code> to the correct value.</p> <p>64 bit systems have a <em>4 level</em> paging system because their memory spaces are much more sparse. Also, it is possible to page sizes that are not 4KB.</p> <p>To actually get to your questions:</p> <ol> <li>All of this paging information (tables, directories etc) sits in kernel memory. Note that kernel memory is one big chuck and there is no concept of having kernel memory for a single process.</li> <li>There is only one page <em>directory</em> per process. This is because the page directory defines a memory space and each process has exactly one memory space.</li> <li>The last paragraph above gives you the way an address is chopped up.</li> </ol> <p>Edit: Clean up and minor modifications.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload