Memory: Using the Page Table
CS 321 Lecture,
Dr. Lawlor, 2006/02/17
The UNIX system calls to manipulate the page table are:
- mmap to put physical memory at a given location in program virtual memory, and optionally copying a file's contents there.
- munmap to remove physical memory from a given location in virtual memory.
- mprotect
changes your access rights on a particular piece of memory. For
example, you can remove your right to write to a particular chunk of
memory.
- brk and sbrk
are older (pre-mmap) calls that adjust the "heap boundary", adding
zero-filled physical memory at the end of the heap virtual address
space. They can now be replaced with calls to mmap.
Here's an example of how to call mmap.
The Windows calls to manipulate the page table are:
- VirtualAlloc
puts physical memory at a given virtual address. You first have
to MEM_RESERVE, then MEM_COMMIT a range of virtual addresses.
- VirtualFree removes physical memory from a given virtual address.