Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.

Similar presentations


Presentation on theme: "Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal."— Presentation transcript:

1 Virtual Memory Pranav Shah CS147 - Sin Min Lee

2 Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal Computer doesn’t have enough memory to handle multiple applications. Computer addresses more main memory than it actually has and store excess on an area of the hard drive called page file. Most common way to implement Virtual Memory is paging, segmentation and a combination of paging and segmentation.

3 Definitions. Virtual Address - The logical or program address that the process uses. Physical Address - The real address in the physical memory. Mapping - The mechanism to translate virtual address into physical. Page Frames - Equal size chunks that main memory is divided into. Pages - Equal size chunks that virtual memory is divided into - equal to the size of a page frame. Paging - Process of copying virtual page from disk to page frame in memory. Fragmentation - The memory that becomes unusable. Page Fault - Occurs when requested page is not in memory and must be copied from disk into memory.

4 Paging. Allocate physical memory to processes in fixed size chunks and keep track of where the various pages of the process reside by recording information in a page table. Every process has its own page table that typically resides in the main memory and the page table stores the physical location of each virtual page of the process.

5 Paging contd. If there are pages of process currently not in the main memory, the page table sets the valid bit to 0; or if the page is already in the main memory then the valid bit is set to 1. More fields can also bee added to relay more information. Example: A modify bit can be added to indicate if the page has been changed.

6 How paging works. When a process generates a virtual address, the operating system must dynamically translate this virtual address into a physical address in memory at which the data actually resides. To accomplish the address translation, a virtual address is split into a page field and a offset field.

7 Example of Paging 2 1 0 1 - 0 1 1 - 0 3 1 - 0 A B C D E F G H I J K L M N O P C D G H A B K L 1 0 1 0 0 1 1 Main Memory Address Program Address Space Page Table Virtual Address 10 10 = 1010 2 Physical Address Frame Valid Bit Page 0 1 2 3 4 5 6 7 Page Frame 0 1 2 3 4 bits( Holds Value K) 3 bits

8 Advantages and Disadvantages of Paging AdvantagesDisadvantages 1.Easy to allocate memory. 2.Easy to “page out” chunks of programs. 1. Can still have internal fragmentation. 2.Memory reference overhead 3.Memory Required to hold page tables can be large.

9 Segmentation In segmentation, virtual address space is divided into logical, variable length units called segments. When segment needs to be copied into physical memory, the OS looks for chunk of free memory large enough to store the entire segment. A segment has a base address, indicating its location in memory, and a bounds limit indicating its size. Similar to Paging, Each program consisting of multiple segments, now has an associated Segment table.

10 External Fragmentation in Segmentation As segments are allocated and de-allocated, the free chunks that reside in memory become broken up. There are many small chunks, but none large enough to store an entire segment. To combat this, the systems use some sort of garbage collection. Garbage collection basically shuffles occupied chunks of memory to turn the smaller, fragmented chunks into larger, usable chunks. (Similar to defragmenting a hard drive)

11 Combination of Paging and Segmentation Virtual Address space is divided into segments of variable lengths, and the segments are divided into fixed- size pages. main memory is divided into the same size frames. Thus, each segment has a page table, which means every program has multiple page tables. Physical Address is divided into 3 fields: the segment field to point to the appropriate page table, the page number to offset into this page table and the offset within the page. Combined, Paging and segmentation is very advantageous as it allows for segmentation from user point of view and paging from system’s point of view.


Download ppt "Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal."

Similar presentations


Ads by Google