Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual Memory Chantha Thoeun. Overview  Purpose:  Use the hard disk as an extension of RAM.  Increase the available address space of a process. 

Similar presentations


Presentation on theme: "Virtual Memory Chantha Thoeun. Overview  Purpose:  Use the hard disk as an extension of RAM.  Increase the available address space of a process. "— Presentation transcript:

1 Virtual Memory Chantha Thoeun

2 Overview  Purpose:  Use the hard disk as an extension of RAM.  Increase the available address space of a process.  Allow multiple applications to run concurrently.  Managed by the operating system.  Implementations:  Paging (most popular)  Segmentation  Combination of both paging and segmentation

3 Terminology  Virtual address  Logical or program address that processes use  Physical Address  Address in physical memory  Mapping  Translating virtual addresses to physical addresses  Page frames  Equal-size chunks physical memory is divided into  Pages  Equal-size chunks virtual memory is divided into  Paging  Process of copying a page to a page frame.  Fragmentation  Memory that becomes unusable  Page fault  An event signaling a requested page is not in physical memory

4 Paging  Basic idea:  Allocate physical memory to processes in fixed size chunks (page frames).  Keep track of the pages of a process by recording information in a page table.  The page table stores the physical location of each page.  The page table stores a valid bit: 0 if the page is currently not in memory, 1 if it is.

5 Paging (cont.)  Internal fragmentation  Pages and page frames are divided into fixed-size chunks.  Unusable space within a given page.  Caused by when a process does not need an entire page frame, but must occupy an entire page frame when loaded into memory.

6 Paging Process 1. Extract the page number from the virtual address. 2. Extract the offset from the virtual address. 3. Translate the page number into the physical page frame number using the page table. A. Look up the page number in the page table B. Check the valid bit for the page. 1. If the valid bit = 0, generate a page fault. a. Locate the desired page on disk. b. Find a free page frame. c. Copy desired page into the free page frame in memory. d. Update the page table. e. Resume execution of the process causing the page fault, continue to step B2. 2. If the valid bit = 1, the page is in memory. a. Replace the virtual page number with the actual frame number. b. Access the data at offset in physical page frame by adding the offset to the frame number.

7 Paging Example

8 Segmentation  Virtual address space is divided into variable-length units, called segments.  Each segment has a base address and a bounds limit, indicating its size.  A program consists of multiple segments, and an associated segment table.  A segment table consists of base/bounds pairs for each segment.

9 Segmentation Example

10 External Fragmentation  Free chunks that reside in memory become broken up.  These broken chunks are too small to store an entire segment.  These small chunks must then be garbage collected to form bigger chunks (similar to defragging a hard drive).


Download ppt "Virtual Memory Chantha Thoeun. Overview  Purpose:  Use the hard disk as an extension of RAM.  Increase the available address space of a process. "

Similar presentations


Ads by Google