Why one page table per process
Asked Answered
D

2

19

At first I thought there is only one page table for the whole system. But there are actually one page table per process? What is the point of having multiple page table instead of one page table.

I am implementing part of os161

Davidadavidde answered 29/11, 2011 at 2:55 Comment(1)
There is only one kernel page table (including page directory) but each process would need a separate one to be able to address virtual space.Raquelraquela
A
20

A page table usually has a fixed number of entries and therefore describes only a portion of the entire virtual address space. This is why you need multiple of them to cover the entire address space. Now, in many OSes processes have individual (in other words, not shared with others) virtual address spaces, which helps to protect processes from one another. This is another reason for having multiple page tables.

Albescent answered 29/11, 2011 at 3:37 Comment(3)
Here's a good explanation as well: en.wikipedia.org/wiki/Virtual_memory#Page_tablesRuebenrueda
And btw, page table is part of the process/task context, when you switch process/task, the page table also needs to get switched.Brandnew
Alexey Frunze, this is partially wrong. I agree, a page table has a fixed number of entries. However, I disagree, a page table describes in fact the entire virtual address space for a process. I mean, for each page of the process, you have an entry in its page table. The reason to have multiple page tables is that each process has its own virtual address space, as said by @marski. A page N of a process P1 is probably not mapped to the same frame in physical memory than a page N of a process P2. As there is a specific mapping for each process, you have a specific page table for each process.Trestlework
E
7

Page table translates from virtual to physical page addresses. Since each process has its own virtual address space and usually maps the same virtual address to a different physical address it needs a separate page table. Curiously, multiple processes may map different virtual addresses to the same physical memory. This can be used to implement shared libraries or inter-process communication.

Expiry answered 12/12, 2019 at 22:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.