Virtual Memory Lei Li CS147.

Slides:



Advertisements
Similar presentations
January is Clean Up Your Computer Month! Here are some tips to make your computer run faster!
Advertisements

Paging: Design Issues. Readings r Silbershatz et al: ,
Chapter 6: Memory Management
Memory Management: Overlays and Virtual Memory
COMP381 by M. Hamdi 1 Virtual Memory. COMP381 by M. Hamdi 2 Virtual Memory: The Problem For example: MIPS64 is a 64-bit architecture allowing an address.
16.317: Microprocessor System Design I
Segmentation and Paging Considerations
CS 153 Design of Operating Systems Spring 2015
Memory Management Norman White Stern School of Business.
Multiprocessing Memory Management
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Organization.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Computer Organization Cs 147 Prof. Lee Azita Keshmiri.
Virtual Memory Deung young, Moon ELEC 5200/6200 Computer Architecture and Design Lectured by Dr. V. Agrawal Lectured by Dr. V.
EECE476: Computer Architecture Lecture 27: Virtual Memory, TLBs, and Caches Chapter 7 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
 Contents 1.Introduction about operating system. 2. What is 32 bit and 64 bit operating system. 3. File systems. 4. Minimum requirement for Windows 7.
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Conventional Memory 8088 processor could address only 1 MB
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Review of Memory Management, Virtual Memory CS448.
1. Memory Manager 2 Memory Management In an environment that supports dynamic memory allocation, the memory manager must keep a record of the usage of.
University of Management & Technology 1 Operating Systems & Utility Programs.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
Hosted Virtualization Lab Last Update Copyright Kenneth M. Chipps Ph.D.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
IT253: Computer Organization
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Chapter 4 Memory Management Virtual Memory.
Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Computer Systems Week 14: Memory Management Amanda Oddie.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
Memory Management: Overlays and Virtual Memory. Agenda Overview of Virtual Memory –Review material based on Computer Architecture and OS concepts Credits.
CS 390 Unix Programming Environment
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.
Teach Yourself Windows 98 Module 3: Using Multimedia Features and Optimizing Your Computer.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management Chapter 5 Advanced Operating System.
Operating Systems Lecture 9 Introduction to Paging Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
The Memory Hierarchy Lecture 31 20/07/2009Lecture 31_CA&O_Engr. Umbreen Sabir.
Virtual Memory By CS147 Maheshpriya Venkata. Agenda Review Cache Memory Virtual Memory Paging Segmentation Configuration Of Virtual Memory Cache Memory.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Virtual Memory.
Virtual Memory So, how is this possible?
Memory Management.
Chapter 2 Memory and process management
Swapping Segmented paging allows us to have non-contiguous allocations
CSCI206 - Computer Organization & Programming
O.S Lecture 13 Virtual Memory.
EECE.4810/EECE.5730 Operating Systems
Main Memory Background Swapping Contiguous Allocation Paging
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CS703 - Advanced Operating Systems
COMP755 Advanced Operating Systems
Presentation transcript:

Virtual Memory Lei Li CS147

What’s Virtual Memory? Virtual memory is a combination of RAM (physical system memory) and reserved hard disk space. The word virtual means "appearing to exist, but not really there."

Virtual memory vs. physical memory During the execution of a program, parts of the program are in physical RAM and other parts are swapped out to the hard disk. Virtual Memory = RAM + hard disk Why is VM important? Cheap ­ no longer have to buy lots of RAM Removes burden of memory resource management from the programmer Other benefits

Virtual memory > RAM Because virtual memory is a combination of RAM and hard disk space, it's possible to have more virtual memory in your system than you have RAM installed. Because Windows uses virtual memory to run programs, it's possible to run more applications simultaneously than would be possible if Windows used only physical memory to run programs.

Virtual memory

The memory pyramid

How Does VM Work ? Two memory “spaces” On program startup Virtual memory space ­ what the program “sees” Physical memory space ­ what the program runs in (size of RAM) On program startup OS copies program into RAM If there is not enough RAM, OS stops copying program and starts it running with only a portion of the program loaded in RAM When the program touches a part of the program not in physical memory (RAM), OS catches the memory abort (called a page fault) and copies that part of the program from disk into RAM In order to copy some of the program from disk to RAM, OS must evict parts of the program already in RAM OS copies the evicted parts of the program back to disk

Example: Virtual and Physical Address Spaces Virtual Address Space Physical Address Space 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C add r1,r2,r3 0x00 0x04 0x08 0x0C add r1,r2,r3 sub r2,r3,r4 sub r2,r3,r4 lw r2, 0x04 lw r2, 0x04 mult r3,r4,r5 mult r3,r4,r5 bne 0x00 add r10,r1,r2 sub r3,r4,r1 sw r5,0x0c

Example (con'td): Need VA­to­PA mappings Virtual Address Space Physical Address Space VA->PA 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C add r1,r2,r3 0x00 0x04 0x08 0x0C add r1,r2,r3 sub r2,r3,r4 sub r2,r3,r4 lw r2, 0x04 lw r2, 0x04 mult r3,r4,r5 mult r3,r4,r5 bne 0x00 add r10,r1,r2 sub r3,r4,r1 sw r5,0x0c

Example (con'td): After handling a page fault Virtual Address Space Physical Address Space VA->PA 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C add r1,r2,r3 0x00 0x04 0x08 0x0C bne 0x00 sub r2,r3,r4 sub r2,r3,r4 lw r2, 0x04 lw r2, 0x04 mult r3,r4,r5 mult r3,r4,r5 bne 0x00 add r10,r1,r2 sub r3,r4,r1 sw r5,0x0c

Example (con'td): After a second page fault Virtual Address Space Physical Address Space VA->PA 0x00 0x04 0x08 0x0C 0x10 0x14 0x18 0x1C add r1,r2,r3 0x00 0x04 0x08 0x0C bne 0x00 sub r2,r3,r4 add r1,r2,r3 lw r2, 0x04 lw r2, 0x04 mult r3,r4,r5 mult r3,r4,r5 bne 0x00 add r10,r1,r2 sub r3,r4,r1 sw r5,0x0c

Basic VM Algorithm Program asks for virtual address Computer translates virtual address (VA) to physical address (PA) Computer reads PA from RAM, returning it to program 0x00 0x04 0x08 0x0C add r1,r2,r3 sub r2,r3,r4 lw r2, 0x04 mult r3,r4,r5 RAM VA->PA Processor (running program) Instructions (or data) Virtual address

Page Tables Table which holds VA ­> PA translations is called the page table In our current scheme, each word is translated from a virtual address to a physical address How big is the page table? VA->PA RAM 0x00 0x04 0x08 0x0C add r1,r2,r3 Processor (running program) sub r2,r3,r4 Virtual address lw r2, 0x04 mult r3,r4,r5 Instructions (or data)

Real Page Tables Instead of the fine­grained VM where any virtual word can map to any RAM word location, partition memory into chunks called pages Typical page size today is 4 or 8 KBytes This reduces the number of VA­> PA translation entries Only one translation per page For a 4 KByte page, that's one VA­> PA translation for every 1,024 words Within a page, the virtual address == physical address Virtual Page Number Page Offset Physical Page # Translation Virtual Address Physical 11 12 31 24

How Can I Find Out How Much Virtual Memory My System Has? Windows can tell you the amount of virtual memory available at any given time and the percentage of your total system resources that are currently available for applications. To get this information, switch to Program Manager, and choose Help/About Program Manager.... At the bottom of the display box, your free memory (virtual memory) and % of free resources are listed. The amount of free memory should be 12 megabytes or more, i.e., 12,000 KB. It is also recommended that your % free be as high as possible.

My system virtual memory

What Causes Free Memory to Decrease? Every time you run an application program under Windows, that program uses some of your free virtual memory to run program code, and to store and display data. Programs use additional memory as they: open new documents execute utility programs (like a spell-checker) perform other related program operations

Optimizing Memory for Use with Windows* optimize your use of existing memory so that the maximum possible amount is available for Windows to access directly: 1, close down some (or all) applications that are running in the background or running minimized. -------In some cases, you'll need to close and restart Windows to achieve the maximum available virtual memory your system can have. (This is because some applications don't de-allocate memory after they're closed.)

Optimizing Memory for Use with Windows* (con) 2, unload memory-resident programs and drivers that load into conventional or extended memory. Note: address range in the system memory Conventional memory: 0-640K upper memory: 640K-1M Extended memory: above 1M.

Optimizing Memory for Use with Windows* (con) Since Windows* can access extended memory directly, and since extended memory is normally available in the largest quantities, freeing up extended memory is usually the most efficient way to gain virtual memory for Windows to use. To free up extended memory, check your system for RAM disks or disk caches that are created from extended memory. Eliminating these or reducing their size will provide more virtual memory for Windows applications.

Increasing the Amount of Virtual Memory in the System Besides optimizing the system memory, we can also increase the amount of virtual memory in the system. There are two ways: --------Increase the amount of system RAM available. --------Create a permanent or temporary swap file.

Increasing the Amount of Virtual Memory in the System(cont) To increase available system RAM, purchase additional memory chips and install them in your computer. To increase the amount of hard disk space allocated as virtual memory, you need to create a Windows swap file, or increase the size of your current Windows swap file.

How to Create, Delete, or Change the Size of a Swap File Open the Windows Control Panel by double clicking the 'Control Panel' icon (usually located in Windows' 'Main' program group). Double-Click on the 386 Enhanced icon in the Control Panel window. Click on Virtual Memory. Click on Change. In the 'New Settings' box, select Permanent or Temporary (See: Permanent Swap Files) from the 'Type' box. Select 'None' to delete an existing swap file. Enter a size in the 'New Size' box. (Skip this step when deleting a swap file). Click on OK. Click on Yes to tell Windows you're sure about making changes to virtual memory. Click on OK to confirm the message that the swap file has been created. Restart Windows when prompted.

For more information, please go to www.intel.com and search on virtual memory