COMP 3500 Introduction to Operating Systems Project 4 – Virtual Memory Part 1: Overview Dr. Xiao Qin Auburn University

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

Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
EECS 470 Virtual Memory Lecture 15. Why Use Virtual Memory? Decouples size of physical memory from programmer visible virtual memory Provides a convenient.
OS Fall’02 Virtual Memory Operating Systems Fall 2002.
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
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.
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Computer ArchitectureFall 2007 © November 21, 2007 Karem A. Sakallah Lecture 23 Virtual Memory (2) CS : Computer Architecture.
Memory Problems Prof. Sin-Min Lee Department of Mathematics and Computer Sciences.
CS 104 Introduction to Computer Science and Graphics Problems
Project 3 -- Page Replacement CS-502 Fall Project 3 Page Replacement in Linux CS-502, Operating Systems Fall 2007 Due, Monday, November 12, 2007.
Memory Management 2010.
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.
CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009.
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Memory Management April 28, 2000 Instructor: Gary Kimura.
CS 241 Section Week #12 (04/22/10).
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Computer Architecture Lecture 28 Fasih ur Rehman.
1 Project: Virtual Memory Manager Lubomir Bic. 2 Assignment Design and implement a virtual memory system (VM) using segmentation and paging The system.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
IT253: Computer Organization
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 203 / NWEN 201 Computer Organisation / Computer Architectures Virtual.
© 2004, D. J. Foreman 1 Virtual Memory. © 2004, D. J. Foreman 2 Objectives  Avoid copy/restore entire address space  Avoid unusable holes in memory.
Memory Management Fundamentals Virtual Memory. Outline Introduction Motivation for virtual memory Paging – general concepts –Principle of locality, demand.
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?
Lecture Topics: 11/24 Sharing Pages Demand Paging (and alternative) Page Replacement –optimal algorithm –implementable algorithms.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Demand Paging Reference Reference on UNIX memory management
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Page Table Implementation. Readings r Silbershatz et al:
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”
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
COMP 3500 Introduction to Operating Systems Paging: Basic Method Dr. Xiao Qin Auburn University Slides.
COMP 3500 Introduction to Operating Systems TLB and Memory Accesses Dr. Xiao Qin Auburn University Slides.
Project 4 Awards First Place Group 7 Samuel Bartlett Michael Phillips Norman Chen.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Virtual Memory Chapter 7.4.
CE 454 Computer Architecture
CS161 – Design and Architecture of Computer
CSCI206 - Computer Organization & Programming
Evolution in Memory Management Techniques
Page Replacement.
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
© 2004 Ed Lazowska & Hank Levy
CSE451 Virtual Memory Paging Autumn 2002
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Computer Architecture
Paging and Segmentation
CS703 - Advanced Operating Systems
CSE 542: Operating Systems
Translation Buffers (TLBs)
Review What are the advantages/disadvantages of pages versus segments?
CSE 542: Operating Systems
Virtual Memory 1 1.
Presentation transcript:

COMP 3500 Introduction to Operating Systems Project 4 – Virtual Memory Part 1: Overview Dr. Xiao Qin Auburn University

Project 4 Submission Awards Group 3 – Gregory Bordelon – Sicheng Li – Wan Lau Group 4 – Wesley Gates – Chase Counsell – Jacob Varner 2

Project 4 Submission Awards Group 6 – Trenton Hines – Anthony Massaro – William White Group 7 – Samuel Bartlett – Norman Chen – Michael Phillips 3

Project 4 Submission Awards Group 8 – Sequoia Harris – Jessica Stell – Jeremy Woods Group 16 – Pamela Cardoso – Alan Hoffman – Blake Johnson 4

5 Learning Objectives TLB faults Virtual Memory Performance Tuning Debugging Skills To Implement a C or C++ program dealing TLB faults. To tune your TLB and memory replacement algorithms. To design a simple virtual memory system Use GDB to debug your C program

Your Misson 6 load a file containing a list of logical addresses Translating AddressLoading Output Values translate logical addresses into physical addresses output the value of the byte stored at the translated physical address.

16-bit Logical Addresses 7

System Parameters Page table size: 28 Number of TLB entries: 16 Page size: 28 bytes Frame size: 28 bytes Number of frames: 256 Physical memory size: 65,536 bytes

A Paging System with Translation Look-aside Buffers (TLB) 9

Address Translations: An algorithm Step 1: page number is extracted from the logical address. Step 2: Access the TLB using the extracted page number. Step 3: Access the page table If TLB-hit, the frame number of the page is obtained from the TLB. If TLB miss, follow step 3 to access the page table. Otherwise, a page fault occurs. If the page has been loaded into the main memory, the frame # of the page is obtained from the page table

What are the two key data structures in the paging system? 11 1.page table 2.TLB

A Question about Page Faults A user program tries to access data at virtual address X. Please describe the conditions under which each of the following can arise. 1.TLB miss, page fault 2.TLB miss, no page fault 3.TLB hit, page fault 4.TLB hit, no page fault

Handling Page Faults You should implement demand paging The backing store is simulated by a file called “BACKING_STORE” BACKING_STORE is a binary file of 65,536 bytes.

Handling Page Faults Step 1: read a 256-byte page from file BACKING_STORE. Step 2: store the loaded page frame in the physical memory Step 3: Update the page table Step 4: Update the TLB

Basic Idea of Virtual Memory: Virtual Memory is Larger Than Physical Memory BACKING_STORE is a simulated hard drive in your system.

Accessing BACKING_STORE BACKING_STORE is a simulated hard drive in your system. BACKING_STORE is accessed as a random-access file: – your VM system can randomly seek to certain positions to this file for reading pages from the simulated disk. Use the standard C library functions for performing file reads, including fopen(), fread(), fseek(), and fclose(). In a future lecture, I will show you how to use the standard C library functions to access BACKING_STORE.

No Page Replacement Your VM system does NOT need to deal with the page replacement issue. Why? The physical memory size equals to the virtual address space.

Collaborations: The First Step To understand how TLB and page faults occur. One group member should study TLB faults one group member should study page faults. Discuss key issues with your group members

Collaborations: Discuss key issues What will your page tables look like? What should you put in each PTE (page table entry)? In what order can TLB faults and page faults occur? (e.g., can a page fault occur without causing a TLB fault?) Review each other's designs.

Collaborations Which requires more time to implement? page fault handling or TLB fault handling. Page fault handling is more difficult to implement than TLB fault handling! Divide VM implementation into several small and well-defined modules Get together as early as possible to share what you each have discovered and designed.

Implementation Idea: Extracting Page Numbers and Offset Implement and test a function is to extract page number and an offset from the following addresses: 1, 256, 32768, 23769, 128, 65534, Use bit-masking and bit-shifting operators. Then integrate this function into your simulated VM System.

Implementation Idea: Page Table Before implement the TLB, you are suggested to implement a page table. Why we want to make sure our system has a functional page table prior to the development of the TLB? The VM system can run without a TLB, the goal of which is to improve the system performance.

The TLB and Paging Modules Your system must handle page faults using the TLB and the page table. Group member 1: implement TLB Group member 2: implement paging integrate these two modules together

Implementation Idea: TLB and its Replacement Strategy TLB has a total of 16 entries Implement two replacement strategies: The TLB state should be initialized properly. 1.FIFO (i.e., First In and First Out). 2. The LRU (i.e., Least Recently Used) strategy to optimize the TLB hit rate.

What you don’t have to implement? You do NOT have to implement a replacement strategy for the page table. You do NOT need to take care of context switch, because there is no process manager in your system. You do NOT have to worry about the kernel. You do NOT have to read OS/161 source code.

Testing File InputFile.txt: – Test your simulated virtual memory system. – Download this file from the Canvas system The file contains: – A list of integers representing logical addresses – Ranging from 0 to 65,535 – Virtual address space. You program must – read all the logical addresses stored in this file, – translate the addresses into corresponding physical addresses, and – output the value of the singed byte at the physical address.

A Small Testing File A small test input file called testinput.txt can be downloaded from Canvas to test your implementation.

Performance Tuning Use the file vm_sim_output.txt as your "lab notebook" for this section. Implement some software counters: – The number of page faults. – The number of TLB faults. Experiment with different TLB replacement strategies (i.e., FIFO and LRU) Tune system parameters

Programming Environment Write your simulated virtual memory system in either C or C++. Compile and run your system using the gcc or g++ compiler on a Linux box (either in Shop 3, computer labs in Shelby, your home Linux machine, a Linux box on a virtual machine, or using an emulator like Cygwin).

Function-Oriented Approach A function should do one thing, and do it well Functions should NOT be highly coupled

Separate Compilation 31