DOC PREVIEW
SJSU CS 147 - Virtual Memory

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory that would otherwise be unused when programs free up data. Physical memory size constraints are also solved by using alternate forms of data storage to act like memory. Implemented via Paging or Segmentation Problem: Thrashing reduces preformanceVirtual MemoryOverview Techniques used to give an application program logical access to contiguous working memory In reality the data is fragmented in primary and secondary memory.Virtual MemoryMemory FragmentationNot just using disk space to extend the physical memory.Uses real physical memory more efficiently.Tricks programs into thinking they are using large blocks of contiguous addresses.Reuses fragments in memory.1950s: Primary memoryMagnetic Core Memory(non-volatile)Virtual Memory: A HistoryVirtual Memory: A History1950s: Secondary memoryDrum Memory (non-volatile)(BSD Unix: /dev/drum is default name for swap)Virtual MemoryOverlaysBefore virtual memory, programs that were too big for the size of physical memory used OverlaysOverlays still popular in embedded systems that require cheap hardwareOverlays require the programmer to manage memory for each program.Virtual MemoryOverlaysProgram manually divided into self-contained code blocks called OverlaysSize of Overlay limited by memory constraints (different for different systems)Programmer had to use specific programming languages or assembly language to have control over the size of the program and the size of the overlay.Virtual MemoryA historyVirtual memory was developed in approximately 1959–1962, at the University of Manchester for the Atlas Computer, completed in 1962.In 1961, Burroughs released the B5000, the first commercial computer with virtual memory. It used segmentation rather than paging.Virtual Memory was controversial and required many theories, models, and experiments before it was adopted. "the machine that everyone loves, and nobody buys"- Brian RandellVirtual MemoryA historyDynamic address translation required a specialized, expensive, and hard to build hardwareWorries that new system-wide algorithms of utilizing secondary storage would be far less effective than application-specific ones.In 1969 an IBM research team led by David Sayre showed that the virtual memory overlay system consistently worked better than the best manually controlled systems.Virtual MemoryPagesVirtual memory address space is divided into pages.A page is a block of contiguous virtual memory addresses that are at least 4096 bytes in size.Pages are managed by Page Tables.Page Tables are kept in memory and translate virtual addresses into physical addresses for use by the hardware.A Page Directory manages Page Tables.There is one page directory per operating system.Visualization of Paging System in Windows NT (32 bit)Page Directory Entry Offset (Per Process)Page Table Entry Offset (Table + Frame)Memory byte offset (4096 bytes in frame)Virtual MemoryPaging“Swapping” is the act of swapping data from physical memory into the virtual memory portion of the hard drive.“Paging” is the act of reading data from the hard drive (not the virtual memory portion) and writing data permanently back to the hard drive.Some Operating Systems use “Paging” to describe both (Windows and its “pagefile” vs Unix and its “swap”)Virtual MemoryPage FaultA Page Fault occurs when a program attempts to access a page that is not current in main memory.The operating system takes over and does the following:1. Determines the location of the data in secondary storage.2. Creates an empty page frame in main memory.3. Loads the data into the empty page frame.4. Updates the Page Table to show the new data.5. Return control to the program, retrying the last instruction which caused the page fault.Virtual MemoryPage FaultIf main memory is full in step 2: Swap out page in memory using an algorithm (most commonly used is discarding based on Least Recently Used)A Page is “Dirty” if it has been modified since it was read from secondary storage.If Page is “Dirty”, the OS writes the changes back to secondary storage. Else, the OS just discards the page.When Page Fault swapping occurs, OS attempts to predict which pages will be used later and load those at the same time.Virtual MemoryPaging StrategiesDemand Paging: No pages are loaded into RAM unless specifically requested by the program. Program starts with NO pages loaded into RAM. Pages of program of the program that are not run will never be loaded.Virtual MemoryPaging StrategiesLoader Paging: Attempts to predict which parts of the program will be loaded. If possible, every page of the program will be loaded into memory at the start of execution.Virtual MemoryPaging StrategiesAnticipatory Paging: Uses the locality of reference to pre-load pages from the program that are most likely to be executed. The goal is to minimize the number of page faults.Virtual MemoryPaging StrategiesSwap Prefetch: A type of anticipatory paging which specifically pre-loads pagesPre-loads pages from program that caused last pagefault.Pre-loads pages that have been swapped out back into memory when a large program releases it's memory in anticipation of the user needing to use the other programs instead.Virtual MemoryPaging StrategiesPre-cleaning: Writes “Dirty” pages back into secondary storage periodically as a syncing mechanism, before page needs to be swapped out.Makes starting a new program much faster as pages that were “Dirty” and would have to be written back to secondary storage are now clean and are just discarded.Virtual MemoryPaging Replacement AlgorithmsTheoretical Optimal Paging AlgorithmFirst In, First OutSecond Chance (Special case of FIFO)Clock (Similar to Second Chance)Least Recently UsedNot Frequently UsedAging (Combines LRU with NFU)RandomVirtual MemoryThrashingThrashing is when the Operating System spends more and more time swapping pages to and from virtual memory on the hard drive than running the programOccurs when the sum of localities from running processes


View Full Document

SJSU CS 147 - Virtual Memory

Documents in this Course
Cache

Cache

24 pages

Memory

Memory

54 pages

Memory

Memory

70 pages

Lecture 1

Lecture 1

53 pages

Cisc

Cisc

18 pages

Quiz 1

Quiz 1

4 pages

LECTURE 2

LECTURE 2

66 pages

RISC

RISC

40 pages

LECTURE 2

LECTURE 2

66 pages

Lecture 2

Lecture 2

67 pages

Lecture1

Lecture1

53 pages

Chapter 5

Chapter 5

14 pages

Memory

Memory

27 pages

Counters

Counters

62 pages

Load more
Download Virtual Memory
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Virtual Memory and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Virtual Memory 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?