160 likes | 488 Views
Case Study: Virtual Memory in UNIX. Reference – Maurice J.Bach , The Design of the UNIX Operating System Terminology - Physical Memory (Main Memory) Secondary Memory (H.Disk) Virtual Memory Swap File. Region. Virtual space of a process Stack , Data , Text – are regions of every process.
E N D
Case Study: Virtual Memory in UNIX • Reference – Maurice J.Bach , The Design of the UNIX Operating System Terminology - • Physical Memory (Main Memory) • Secondary Memory (H.Disk) • Virtual Memory • Swap File
Region • Virtual space of a process • Stack , Data , Text – are regions of every process
Per Process Region Table - pregion • For every region – • Starting virtual address • Number of pages in this region • Access mode • Pointer to the Page Table (page table for every region)
Page Table Entry • Demand paging fields • Valid • Reference • Modify • Copy on Write (COW) • Age • Modify , Reference -handle by the hardware
More tables • Page frame data table (pfdata) • One table • Mapping all physical frames to disk • Tells how many process are using this frame • List of free frames • Hash from disk address to frame • Swap-use • For every swap device • Tells how many frames points to the same disk address
Kernel process for Virtual Memory • Pager • Every time the OS needs to swap a virtual page to the physical memory • Get the first frame from the list of free pages , if the Modify bit is set write it’s data to the disk. • Load the page to this frame • Set the valid bit • Resume the waiting process • Page Stealer (page daemon) • Every period of time • Enter old frames to the list of free pages • Update the age of every valid frame if the reference bit is 0 • Put 0 in the the reference bit • => LRU with second chance
Page Fault Page Frames Page Table Entries Disk Block • Some of the possibilities : • The page is in the swap file • The page is in the list of free pages After Swapping Page into Memory
Event - Page Daemon done Event – Proc A reads from Pg2 Event – Proc A call to fork()
Event – Proc A reads from Pg1 Event – Proc B write to Pg6 Event – Page Daemon done
Event – Proc B reads from Pg2 & Pg5 Event – Page Daemon done Event – Proc A ends