1 / 13

CS 6560 Operating System Design

CS 6560 Operating System Design. Lecture 15 Process Address Space Page Cache. References. Textbook, chapters 14 and 15. The Memory Descriptor. Called mm_struct and referenced by current->mm_struct Represents a process’ address space Contains Reference to memory areas As a linked list

morton
Download Presentation

CS 6560 Operating System Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 6560 Operating System Design Lecture 15 Process Address Space Page Cache

  2. References • Textbook, chapters 14 and 15

  3. The Memory Descriptor • Called mm_struct and referenced by current->mm_struct • Represents a process’ address space • Contains • Reference to memory areas • As a linked list • Reference to search tree • Reference counts for • Users and processes • Start and end addresses for • Code • Data • Heap • Stack • Command arguments • Environmental variables • Paging information

  4. Memory Descriptor • Sharing • Can be shared within thread group • Allocation • by mm_struct slab allocator • Deallocation • Decrement reference count • If zero, put back in mm_struct cache • Use by kernel threads • Current->mm_struct is null • Share page tables with whatever process was last

  5. Memory Areas • Virtual Memory Area = VMA • VMA_struct represents single memory area (object) over a contiguous interval in an address space. • Has • Reference to address space • Start and end address • Reference for membership in a list of memory areas • Access permissions • Inode reference • Flags • Operations • File reference

  6. VMA Flags • Many flags control properties (page: read, write, execute, shared; growth: up down; file: write and execute; locking; device type; and more • VM_READ - pages can be read • VM_WRITE - pages can be written to • VM_EXEC - pages can be executed • VM_SHARED - pages can be shared • VM_MAYREAD - VM_READ flag can be set • …. (see page 257)

  7. VMA Operations • Operations • Open - invoked when this VMA is added to address space • Close - invoked when this VMA is removed from address space • Nopage - invoked by page fault handler when a page is not present in memory • Populate - called when remap_pages system call is called. (see man 2 mremap)

  8. Example • Use pmap or /proc/xxx/maps, where xxx is the PID of a process

  9. System Calls • Mmap, mmap • Establishes a mapping between a memory interval on the process’ address space and a file or shared memory object. • creates a new linear address interval. Either joins existing VMA or creates new one. • Implemented by do_mmap. • Uses page tables to do the mapping • Mmap • Removes memory mappings. • Implemented by do_mmunmap

  10. Page Cache • Page cache is used for caching virtual memory pages between primary and secondary storage. • Consists of physical pages in RAM • Pages originate in a variety of actions • Reading and writing regular files • Blocks of block devices • Memory-mapped files

  11. Reading and Writing Pages • Reads happen immediately, but writes are delayed. • Generic code for reading and writing is in mm/filemap.c page: • do_generic_readpage • Searches cache for page • If the page exists get the data • If the page does not exit, creates new structure, adds it to the cache, reads page from disk and return data to user buffer • Writing • Whenever page is modified, call set_dirty • Writing is delayed and done in stages, placing the data in the page cache each time.

  12. Page Cache and Block I/O • Each page can consist of several blocks in the block I/O system.

  13. Page Daemons • Pdflush • Writes dirty pages to disk • When free memory is smaller than a limit, writes dirty pages to disk • When dirty data gets too old • Can spawn multiple copies of itself and terminate threads as needed.

More Related