IT253: Computer Organization

Slides:



Advertisements
Similar presentations
Virtual Memory In this lecture, slides from lecture 16 from the course Computer Architecture ECE 201 by Professor Mike Schulte are used with permission.
Advertisements

Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
Caching IV Andreas Klappenecker CPSC321 Computer Architecture.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Translation Buffers (TLB’s)
Virtual Memory. Why do we need VM? Program address space: 0 – 2^32 bytes –4GB of space Physical memory available –256MB or so Multiprogramming systems.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
©UCB CS 162 Ch 7: Virtual Memory LECTURE 13 Instructor: L.N. Bhuyan
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
11/10/2005Comp 120 Fall November 10 8 classes to go! questions to me –Topics you would like covered –Things you don’t understand –Suggestions.
Lecture 33: Chapter 5 Today’s topic –Cache Replacement Algorithms –Multi-level Caches –Virtual Memories 1.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Computer Architecture Lecture 28 Fasih ur Rehman.
CMP 301A Computer Architecture 1 Lecture 4. Outline zVirtual memory y Terminology y Page Table y Translation Lookaside Buffer (TLB)
Lecture 19: Virtual Memory
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
Operating Systems COMP 4850/CISG 5550 Page Tables TLBs Inverted Page Tables Dr. James Money.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
How to Build a CPU Cache COMP25212 – Lecture 2. Learning Objectives To understand: –how cache is logically structured –how cache operates CPU reads CPU.
10/18: Lecture topics Memory Hierarchy –Why it works: Locality –Levels in the hierarchy Cache access –Mapping strategies Cache performance Replacement.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
Fall 2000M.B. Ibáñez Lecture 17 Paging Hardware Support.
Virtual Memory. DRAM as cache What about programs larger than DRAM? When we run multiple programs, all must fit in DRAM! Add another larger, slower level.
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
1 Some Real Problem  What if a program needs more memory than the machine has? —even if individual programs fit in memory, how can we run multiple programs?
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
COMP SYSTEM ARCHITECTURE HOW TO BUILD A CACHE Antoniu Pop COMP25212 – Lecture 2Jan/Feb 2015.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1 Chapter Seven CACHE MEMORY AND VIRTUAL MEMORY. 2 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
CHAPTER 3-3: PAGE MAPPING MEMORY MANAGEMENT. VIRTUAL MEMORY Key Idea Disassociate addresses referenced in a running process from addresses available in.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
3/1/2002CSE Virtual Memory Virtual Memory CPU On-chip cache Off-chip cache DRAM memory Disk memory Note: Some of the material in this lecture are.
CS203 – Advanced Computer Architecture Virtual Memory.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
CS161 – Design and Architecture of Computer
Translation Lookaside Buffer
Lecture 11 Virtual Memory
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Memory Management Virtual Memory.
Virtual Memory Chapter 7.4.
ECE232: Hardware Organization and Design
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
Virtual Memory User memory model so far:
Outline Paging Swapping and demand paging Virtual memory.
Morgan Kaufmann Publishers
CSCI206 - Computer Organization & Programming
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Virtual Memory 4 classes to go! Today: Virtual Memory.
Andy Wang Operating Systems COP 4610 / CGS 5765
Lecture 29: Virtual Memory-Address Translation
Andy Wang Operating Systems COP 4610 / CGS 5765
Chap. 12 Memory Organization
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
CSE451 Virtual Memory Paging Autumn 2002
Translation Buffers (TLB’s)
Translation Buffers (TLBs)
Sarah Diesburg Operating Systems CS 3430
Andy Wang Operating Systems COP 4610 / CGS 5765
Review What are the advantages/disadvantages of pages versus segments?
Sarah Diesburg Operating Systems COP 4610
Presentation transcript:

IT253: Computer Organization Tonga Institute of Higher Education IT253: Computer Organization Lecture 12: Virtual Memory

Extending the Memory Hierarchy We know about registers, cache and RAM. We can add a hard drive for virtual memory. The HD will be really slow, really big and really cheap.

Why do we need Virtual Memory? In our programs, we have addresses of 32 bits. That means there can be about 4 billion addresses we can use. If each entry uses 8 bits (1 byte), then we would need about 4 GBs of memory to hold all the spaces. Most RAM and cache combined is not more than 300 MB, so what if we actually need all that space? Virtual memory uses the hard drive to save memory When we are using virtual memory, it will slow the computer down a lot. A lot of cycles will be wasted waiting for the data or instruction to come all the way from the hard drive. Virtual Memory is an important concept that not only gives us a lot more space, but also lets programs believe they have all the memory to themselves

Virtual Memory The processor will give a memory space (virtual addresses) to each program, The program will not know if the data is in physical memory or if it is in virtual memory There is hardware that can translate the address into either physical or virtual memory. The program using the memory doesn’t care about where the memory actually is

Virtual Memory We have always thought about virtual memory as memory that is used on a hard drive. Virtual memory, in operating systems, is really known as the memory that is given to a program so that it believes it has access to the full range of 32 bits of memory addresses The memory might be on the hard drive or the main memory. The program does not care where it is though, because it does not know where it is

Pages The program will use the virtual address space and only know about things in memory called "pages." Each page will be connected to either a place in physical memory or virtual memory. There is hardware that can change a Page address to a physical frame address in RAM or in the HD

Address Mapping V = {0…n-1} – Virtual Address Space M = {0…m-1} – Physical address space n > m (there are more virtual addresses than physical) MAP function: V  M to get the real address

Page Table The operating system will keep a separate Page Table for each program that runs. The program really only has a small part of the memory and it must share with other running programs A Page Table Entry helps keep important information: Virtual to Physical mapping Valid Bit – make sure the data is good Access Rights – the operating system will say if the program is allowed to read, write, or delete a page of memory There are many ways to design this Page Table

Address Mapping Algorithm If (ValidBit == good) Then the data is in main memory. If it is not good, then the data is in secondary storage (hard drive) If (ValidBit != good) Called a Page Fault because the data is not in main memory and the data must be search for on the hard drive. The program will have to wait while the data is retrieved. (While the program waits, the operating system takes over to get the data. This is called a context switch)

Virtual to Physical Translation

Page Table Design: Linear Design Simplest design. Virtual page number is an index right into the page table. Then it gets the real address

How do we choose a page size? If page is too small: We have a lot of misses and a big page table If page is too big: Fragmentation: we only use part of the page and don’t need the other memory inside because it's too large Smaller page tables As computers get faster, pages are increasing in size We also need a page replacement policy, which will be just like the cache replacement policy (least recently used) Important: Virtual memory is virtual, because it is managed by the operating system. Cache and physical memory is implemented in hardware

Translation Lookaside Buffer We want to a fast way to get the translated address. This can be accomplished if there is a "buffer" or a list of already translated addresses. This is called the TLB (translation lookaside buffer). It is like a cache for page table entries We want to make the common case very fast, and we want to use locality. If we use something often, it should be very fast to get to. The TLB helps us find the things we use often

Translation Buffer (fast translation) We can keep a cache of translated addresses. For example, if we have 64 translated addresses, we can increase the speed of our address translation by a lot

The TLB What do we need to do to make it work well? Must be fast and not make the processor slow down Should have high hit ratio Must be able to change with physical memory (when something is removed, it should be updated) It must allow for multiple programs. (Each program will have it’s own page table where it thinks it own all of memory) Should only have a small number of entries so it can be fast

Hardware TLB The hardware will handle TLB misses and tell the page table how it should be organized. Lot of circuits are needed in the hardware to keep data up to date. Forces the page table to be one way and cannot improve if a new method is invented

Software TLB Software handles the misses. It will put in entries from the page table into the TLB Allows for flexible page table. With hardware, the page table is built into hardware and cannot be changed

Virtual Memory: Mini-Review Provides illusion of large memory Sum of memory of all programs greater than physical memory Address space of each program bigger than physical memory Allows us to use main memory efficiently Uses memory hierarchy to try to make memory fast Virtual Address – address used by the program Virtual Address Space – all the addresses the program thinks it can use Memory Address – address in physical memory. It is the real address

Paged Virtual Memory We can divide memory into pages, blocks, and frames. They are different words but just mean the same thing, a way to divide up memory into separate pieces Pages are used in virtual memory Frames are used for real memory Pages can be mapped into frames in real memory (TLB) Pages can live anywhere: main memory or secondary memory (the hard disk)

Paged Virtual Memory All programs are written to use the virtual memory space. Programs are not allowed to directly control main memory, they can only change virtual memory This is because it would be bad if one program could change another program’s memory. Each program can only see it's own memory Hardware or software will do the translation “on-the-fly” which means it will translate the address when it is being used We use a page table to translate between virtual and physical A TLB helps make the translation go faster

Summary Virtual memory does a few important tasks for a computer It increases the size of memory far beyond what is actually in the RAM by using the hard disk It lets each program think they have their own special world of memory. Makes sure programs cannot access the memory of other running programs Virtual memory uses pages, page tables and TLBs in order to accomplish these tasks.