1

What is the relationship between address space and page table? I know that each process should have a page table which maps between virtual address to physical address. But what does an address space do? in os161, address space looks like:

struct addrespace {
    vaddr_t as_vbase1;
    paddr_t as_pbase1;
    size_t as_npages1;
    vaddr_t as_vbase2;
    paddr_t as_pbase2;
    size_t as_npages2;
    paddr_t as_stackpbase;
}

we translate the virtual address (vaddr) to physical address using: (assume vaddr in segment 1)

paddr = vaddr - as_vbase1 + as_pbase1

it seems that we can get the physical address from the virtual address using the addrespace. If we can use addrespace to do the virtual to physical memory mapping, why do we need the page table?

Looking forward to your help! Thanks!

nuynait
  • 1,912
  • 20
  • 27

1 Answers1

2

Firstly, thanks a lot for this question. Even though I am still a newbie to OS161 and struggling to understand the code, I will tell you what I have understood till now. Please feel free to correct me.

We need a page table to keep track of all the pages assigned to our process, not just because we need a translation from virtual to physical address translation.

The page table also keeps track of the pages if they are in memory and if the required page is on the disk, which would trigger a page fault. In that case we should allocate a new page, load a page from the disk, update page table, and update TLB entries.

Any page undergoes different states like free, dirty (should be written to the disk), etc. There are certain pages which are never supposed to be swapped out and they always remain in memory. Page tables also keep track of these states too.

Even this article might help you.. Why one page table per process

Mike R
  • 302
  • 1
  • 5
  • 14
user1079065
  • 2,085
  • 9
  • 30
  • 53
  • Thanks. Sorry that I lost my account for amount of time . But thanks you very much for your time and help. – nuynait Jun 14 '14 at 16:15