Page Directory, Page table and Memory Mapping Functions

Page Directories and Page Tables 
Page directories and the page tables for the user and the kernel segment is managed by the kernel itself.
The short identifier for the page directory is pgd, pmd (page middle directory) and the short identifier for the page table is pte.
The data type for the page directory and the page table is respectively pgd_t, pmd_t and pte_t. 

Functions  relevant to Page directory
  • pgd_val(), pmd_val() - These functions allow to access the real value of the directory entry (either 32 bit or 64bit).
  • pgd_alloc(), pmd_alloc() - provides the memory page for the respective page directory.  
  • pgd_free(), pmd_free() - The directories are freed.
  • pgd_clear, pmd_clear() - deletes the entry in the page directory.
  • pgd_present, pmd_present() - checks whether the directoryentry refers to the page middle directory or page table, returns apositive result if there is an entry present, else returns a negativevalue.
  • pgd_none(), pmd_none() - just the reverse of pgd_present(), pmd_present()
  • set_pgd(), set_pmd() - the kernel fills the page directory and the page middle directory with entries.
Functions related to page tables
  • pte_val() -returns the value of the page table
  • pte_alloc(), pte_alloc_kernel() -allocating the page table entry
  • pte_free(), pte_free_kernel() - free a page table,
  • pte_page() -page table entry finds a pointer into the mem_map which contains all the physical memory pages of the computer.
  • set_pte() -the values of the page table entry are set, but the entry must either not be present or cannot be updated by the hardware.
Memory Mapping Functions

In the header file sys/mman.h, the functions about memory mapping is provided
extern __ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t off);
From the offset off, mmap() maps the file or the device to which the file descriptor fd refers as virtual memory area. There is also a flag to be used for anonymous mapping.
extern int munmap(_ptr_t addr, size_t len);
The above function is to unmap the memory that is already mapped to the user segment.
extern int mprotect(_ptr_t addr, size_t len, int prot);
the above function is to be provide new protection attributes to the particular area of the memory.

Comments

Popular Posts