umbesco
umbesco

Reputation: 11

how the paging of pages works in unix systems?

I'm trying to study the "Understanding Linux kernel" book, but I stopped to the section "Regular paging". Now, I understood why is the paging needed, what's the concept under it, but... I can't understand a lot of things. Why is the paging of table page(s? I can't remember) necessary and how it works? I mean, yes, the size of one table page would be too big, but, if in the conversion between linear and physical address the kernel selects some table page according to the first part of lin. add., it has to find the whole set of table page somewhere in the ram, so... just why not make one giant table page, if the space is already wasted? And then, the book says that the dimension of each entry in the table page is of 32 bit, but... if the pages are of 4kb, why not use this fact? we know that the last 12 bits are 0s, so why don't leave them implicit? I know that all theese things I said are wrong, I said them just for better explain my doubts. (sorry for shitty English)

Upvotes: 1

Views: 375

Answers (1)

mevets
mevets

Reputation: 10445

Breaking the page descriptors into multiple tables has these benefits:

  1. Granularity. If your program only uses three pages (text, data, stack) all of those page descriptors could be in one page table, and the memory overhead would be very low -- one leaf page table plus a few internal nodes.

  2. Sparseness. Akin to efficiency, the root (directory) table need only contain entries for the parts of the address space that are valid; the rest of the table pointers can be set to invalid pages, so there is no need to populate them.

  3. Sharing. It is very possible that not just memory, but page tables themselves can be shared between processes for large shared memory objects. IIRC solaris called this 'intimate shared memory' (ISM). Similarly, things like kernel mappings may be entirely shared between multiple processes.

  4. Performance. Common 64bit architectures use a 47 bit address space. With 4k page granularity, a linear map would require 2^35 page descriptors each 8 bytes. Just zeroing that amount of ram takes 48s on my creaking mac pro. That would be the cost of starting a process.

Upvotes: 1

Related Questions