Christo Wilson Project 3: Virtual Memory in Pintos

Slides:



Advertisements
Similar presentations
CS 140 Project 3 Virtual Memory
Advertisements

Christo Wilson Project 2: User Programs in Pintos
CS 4284 Systems Capstone Godmar Back Virtual Memory – Paging Techniques.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
1 Pintos Project #3 Virtual Memory The following slides were created by Xiaomo Liu and others for CS 3204 Fall And Modified by Nick Ryan for Spring.
May 7, A Real Problem  What if you wanted to run a program that needs more memory than you have?
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.
1 A Real Problem  What if you wanted to run a program that needs more memory than you have?
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Jaishankar Sundararaman
CS 4284 Systems Capstone Project 2 Hints Slides created by Jaishankar Sundararaman.
1 Virtual Memory vs. Physical Memory So far, all of a job’s virtual address space must be in physical memory However, many parts of programs are never.
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
Memory Management 2010.
Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 121 Today’s class Operating System Machine Level.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Christo Wilson Project 4: File System in Pintos
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.
CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
Operating Systems ECE344 Ding Yuan Paging Lecture 8: Paging.
Project 1. Goals  Write a simple TCP/IP client that supports a specific protocol  The server is running right now on login.ccs.neu.edu:27993  If your.
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
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.
CS 4284 Systems Capstone Godmar Back Virtual Memory – Paging Techniques.
Chapter 4 Memory Management Virtual Memory.
Nachos Tutorial Courtesy: University of Waterloo.
Virtual Memory 1 Chapter 13. Virtual Memory Introduction Demand Paging Hardware Requirements 4.3 BSD Virtual Memory 4.3 BSD Memory Management Operations.
CS399 New Beginnings Jonathan Walpole. Virtual Memory (1)
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?
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
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.
Processes and Virtual Memory
CS307 Operating Systems Virtual Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Implementation.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Project 2: User Programs Abdelmounaam Rezgui Acknowledgment: The content of some slides is partly taken from Josh Wiseman’s presentation.
1 Pintos Virtual Memory Management Project (CS3204 Spring 2006 VT) Yi Ma.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Pintos project 3: Virtual Memory Management
CS 3204 Operating Systems Godmar Back Lecture 16.
Lecture 14 PA2. Lab 2: Demand Paging Implement the following syscalls xmmap, xmunmap, vcreate, vgetmem/vfreemem, srpolicy Deadline: November , 10:00.
CSCI 156: Lab 11 Paging. Our Simple Architecture Logical memory space for a process consists of 16 pages of 4k bytes each. Your program thinks it has.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
Virtual Memory – Paging Techniques
CS 140 Lecture Notes: Virtual Memory
Jonathan Walpole Computer Science Portland State University
CS161 – Design and Architecture of Computer
Memory Caches & TLB Virtual Memory
Chapter 9: Virtual Memory
CS510 Operating System Foundations
Lecture 28: Virtual Memory-Address Translation
CS 140 Lecture Notes: Virtual Memory
Chapter 9: Virtual-Memory Management
What Happens if There is no Free Frame?
CS 140 Lecture Notes: Virtual Memory
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE451 Virtual Memory Paging Autumn 2002
Lecture 7: Flexible Address Translation
CS 140 Lecture Notes: Virtual Memory
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.
Buddy Allocation CS 161: Lecture 5 2/11/19.
Presentation transcript:

Christo Wilson Project 3: Virtual Memory in Pintos 8/22/2012 CS 5600 Computer Systems Project 3: Virtual Memory in Pintos Defense

Virtual Memory in Pintos Pintos already implements a basic virtual memory system Can create and manage x86 page tables Functions for translating virtual addresses into physical addresses But this system has limitations No support for swapping pages to disk No support for stack growth No support for memory mapping files

Your Goals Implement page swapping Implement a frame table If memory is full, take a page from physical memory and write it to disk Keep track of which pages have been moved to disk Reload pages from disk as necessary Implement a frame table Once memory becomes full, which pages should be evicted? Implement a swap table Maps pages evicted from memory to blocks on disk

Your Goals (cont.) Implement stack growth In project 2, the stack was limited to one page Allow the stack to grow dynamically Implement mmap() and munmap() i.e. the ability to memory map files Create a table that keeps track of which files are mapped to which pages in each process

What Pintos Does For You Basic virtual memory management User processes live in virtual memory, cannot access the kernel directly Kernel may access all memory Functions to create and query x68 page tables Trivial filesystem implementation You can read and write data to disk Thus, you can read and write memory pages

Utilities threads/pte.h threads/vaddr.h userprog/pagedir.c Functions and macros for working with 32-bit x86 Page Table Entries (PTE) threads/vaddr.h Functions and macros for working with virtualized addresses Higher-level functionality than pte.h Useful for converting user space pointers into kernel space userprog/pagedir.c Implementation of x86 page tables

Page fault handler: userprog/exception.c static void page_fault (struct intr_frame *f) { bool not_present, write, user; void *fault_addr; /* Fault address. */ asm ("movl %%cr2, %0" : "=r" (fault_addr)); /* Obtain faulting address*/ intr_enable (); page_fault_cnt++; /* Count page faults. */ /* Determine cause. */ not_present = (f->error_code & PF_P) == 0; /* True: not-present page, false: writing r/o page. */ write = (f->error_code & PF_W) != 0; /* True: access was write, false: access was read. */ user = (f->error_code & PF_U) != 0; /* True: access by user, false: access by kernel. */ /* Code for handling swapped pages goes here! */ printf ("Page fault at %p: %s error %s page in %s context.\n”, …); kill (f); }

Supplementary Page Tables The format of the page table is defined by the x86 standard You can’t modify or add to it Thus, you will need to define additional data structures Supplementary page tables Keep track of info for eviction policy, mapping from swapped memory pages to disk, locations of memory mapped files, etc.

Project 3 Is Open Ended The previous projects were about you extending the functionality of Pintos In this, you are free to implement things however you wish pintos/src/vm/ is basically empty

Key Challenges Choosing the right data structures Handling page faults Time and memory efficiency are critical Hash tables? Lists? Bitmaps? You don’t need to implement more exotic data structures (e.g. red-black trees) Handling page faults All swapping is triggered by page faults Handling them, and restarting the faulting instruction, are critical

More Key Challenges Implementing eviction Detecting stack growth How do you choose which page to evict? Detecting stack growth You will need to develop heuristics to determine when a process wants to grow the stack Managing concurrency Pages can be evicted at any time What happens if the kernel or a process is accessing them?

Extra Credit Challenge! Implementing Sharing What happens if a program is run >1 time? You could share the code pages What happens if >1 process mmap()s the same file? Worth an additional two points So 17 out of 15

Things Not To Worry About Your supplementary data structures may live in kernel memory i.e. they will never get swapped to disk In a real OS, page tables may be swapped to disk

Modified Files Makefile.build 4 threads/init.c 5 threads/interrupt.c 2 threads/thread.c 31 threads/thread.h 37 userprog/exception.c 12 userprog/pagedir.c 10 userprog/process.c 319 userprog/syscall.c 545 userprog/syscall.h 1 vm/<new files> 628 11+ files changed, 1594 insertions, 104 deletions Add new files Initialize supplementary tables for the system and per thread Modified page fault handler Support for mmap() syscall Swapping implementation

Grading 15 (+2) points total To receive full credit: Turn in working, well documented code that compiles successfully and completes all tests (50%) Turn in a complete, well thought our design document (50%) If your code doesn’t compile or doesn’t run, you get zero credit Must run on the CCIS Linux machines! All code will be scanned by plagiarism detection software

Turning In Your Project Register yourself for the grading system $ /course/cs5600f14/bin/register-student [NUID] Register your group All group members must run the script! $ /course/cs5600f14/bin/register project3 [team name] Run the turn-in script Two parameters: project name and code directory $ /course/cs5600f14/bin/turnin project3 ~/pintos/src/

DUE: November 12 11:59:59PM EST Questions?