Computer Architecture Lecture 28 Fasih ur Rehman.

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

1 Memory hierarchy and paging Electronic Computers M.
1 Lecture 13: Cache and Virtual Memroy Review Cache optimization approaches, cache miss classification, Adapted from UCB CS252 S01.
OS Fall’02 Virtual Memory Operating Systems Fall 2002.
Computer Organization CS224 Fall 2012 Lesson 44. Virtual Memory  Use main memory as a “cache” for secondary (disk) storage l Managed jointly by CPU hardware.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
OS Spring ‘04 Paging and Virtual Memory Operating Systems Spring 2004.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
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.
Paging and Virtual Memory. Memory management: Review  Fixed partitioning, dynamic partitioning  Problems Internal/external fragmentation A process can.
Chapter 3.2 : Virtual Memory
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.
Computer Organization and Architecture
Virtual Memory I Chapter 8.
Computer Architecture Part III-C: Memory Access and Management.
VIRTUAL MEMORY. Virtual memory technique is used to extents the size of physical memory When a program does not completely fit into the main memory, it.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Address Translation Mechanism of 80386
Cosc 3P92 Week 9 & 10 Lecture slides
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
CMP 301A Computer Architecture 1 Lecture 4. Outline zVirtual memory y Terminology y Page Table y Translation Lookaside Buffer (TLB)
Lecture 19: Virtual Memory
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
IT253: Computer Organization
Fall 2000M.B. Ibáñez Lecture 17 Paging Hardware Support.
Virtual Memory 1 1.
Computer Architecture Lecture 27 Fasih ur Rehman.
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.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
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)
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
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”
Operating Systems Session 7: – Virtual Memory organization Operating Systems.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 33 Paging Read Ch. 9.4.
Computer Architecture Lecture 25 Fasih ur Rehman.
Memory: Page Table Structure CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Virtual Memory Chapter 8.
CS161 – Design and Architecture of Computer
Memory: Page Table Structure
Translation Lookaside Buffer
Basic Paging (1) logical address space of a process can be made noncontiguous; process is allocated physical memory whenever the latter is available. Divide.
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Computer Organization
Virtual Memory Chapter 7.4.
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Today How was the midterm review? Lab4 due today.
CS 704 Advanced Computer Architecture
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Lecture 29: Virtual Memory-Address Translation
Translation Lookaside Buffer
Memory Management by Segmentation
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE451 Virtual Memory Paging Autumn 2002
CSC3050 – Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Translation Buffers (TLBs)
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Review What are the advantages/disadvantages of pages versus segments?
Virtual Memory 1 1.
Presentation transcript:

Computer Architecture Lecture 28 Fasih ur Rehman

Last Class Memories – Performance Considerations – Virtual memory

Today’s Agenda Memories Virtual memory – Address Translation Memory Management

Virtual Memory Physical memory not as large as address space spanned by processor – E.g. processor might address 32-bits (4G) but memory may only be 1G Part of program not in main memory stored on hard disk and brought into main memory (using DMA) as needed This is done automatically by the OS, application program does not need to be aware of the existence of virtual memory (VM) Addresses generated by the processor are called virtual or logical addresses Memory management unit (MMU) translates virtual addresses to physical addresses

Virtual Memory Organization

Address Translation Memory divided into pages of fixed size – A page is a block of words occupying contiguous addresses in MM – A basic unit of information that is exchanged between MM and secondary storage – Commonly size ranges from 2KB to 16KB – Too small means too much time will be spent in getting pages from disk – Too large means a large portion of the page may not be needed or reference Processor generates virtual addresses. – High order bits (most significant bits) are the virtual page number and low order bits (least significant bits) are the offset

Address Translation Information about where each page is stored is maintained in a software controlled data structure in main memory called the page table – Starting address of page table is called the page table base register – Area of the main memory that can hold a page is called page frame – Address in physical memory is obtained by indexing the virtual page number from the page table base register

Address Translation Address of the page table. PTBR + virtual page number = Entry of the page in the page table. Starting address of the page in the main memory. Starting location of the page. Virtual address = page number + offset.

Page Table Page table entries (PTE) also include – Control bits describe status of page Whether page is actually in the memory Whether the page has been modified Does program have read permission Does program have write permission

Page Table Page table is used by Memory Management Unit (MMU) for every read and write request So where should we place the page table? – Ideally, MMU will be ideal place for page table. – Page table size is huge. – Since MMU is part of the processor this much memory cannot be made part of the MMU – So page table is implemented on the main memory To speed up the access, a copy of small portion of the page table can be implemented within the MMU – This small cached table is called Translation Lookaside Buffer (TLB) TLB operates similar to cache memory

Translation Lookaside Buffer Associative or set associative scheme normally used Processor must keep TLB and page table information consistent

Associative Mapped TLB High-order bits of the virtual address generated by the processor select the virtual page. These bits are compared to the virtual page numbers in the TLB. If there is a match, a hit occurs and the corresponding address of the page frame is read. If there is no match, a miss occurs and the page table within the main memory must be consulted. Commercial processors use set-associative mapped TLBs.

How VM Works A page fault is said to occur if a program generates an access to a page that is not in the memory. – MMU generates exception – Processing of active task is suspended – Operating System (OS) take control – OS transfers the required page to MM from the secondary storage (SS) – Suspended program gets the control back after the page has been copied to the MM – Since secondary storage is accessed, the page transfer may cause a significant delay

How VM Works A page has to be brought in MM from the disk but MM is full – An approach similar to cache implementation can be used – Principal of Locality of Reference can be applied here – Least recently used algorithm can be used here A page may be modified during its stay in MM – If such a page (dirty page) is to be replaced – Write back protocol is used Write through protocol will be too slow

Memory Management OS is responsible for transferring programs and data between MM and SS OS routines also occupies some of the virtual space called system space Application program occupies another part of space called user space Processor uses two states – Supervisor state – User state

Memory Management Supervisor state: only OS routines are executed User state – User/Application programs are executed – Certain privileged instructions can be executed in user state – Prevents access of other user space

Summary Virtual Memory – Address Translation – Memory Management