Paging-Example-Question 22:15:57 paging-example-os161-question.txt 1 A system implements paging using a page size of 4096 (2^12) bytes.

Similar documents
CS 153 Design of Operating Systems Winter 2016

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Virtual Memory. Computer Systems Principles

Virtual Memory I. Jo, Heeseung

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CSE 153 Design of Operating Systems

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

Computer Structure. X86 Virtual Memory and TLB

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

Lecture 19: Virtual Memory: Concepts

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14

2-Level Page Tables. Virtual Address Space: 2 32 bytes. Offset or Displacement field in VA: 12 bits

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

A Few Problems with Physical Addressing. Virtual Memory Process Abstraction, Part 2: Private Address Space

Virtual Memory. Yannis Smaragdakis, U. Athens

CS 153 Design of Operating Systems Winter 2016

Virtual Memory 2. To do. q Handling bigger address spaces q Speeding translation

Swapping. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Virtual Memory. Today. Handling bigger address spaces Speeding translation

CS 537: Introduction to Operating Systems Fall 2015: Midterm Exam #1

CSE 120 Principles of Operating Systems Spring 2017

Virtual Memory 1. To do. q Segmentation q Paging q A hybrid system

Virtual Memory III. Jo, Heeseung

Swapping. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

VIRTUAL MEMORY. Operating Systems 2015 Spring by Euiseong Seo

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

Virtual Memory 2. Today. Handling bigger address spaces Speeding translation

CSC C69: OPERATING SYSTEMS. Tutorial Thursday, March 28, 2013 Ioan Stefanovici

CSE 451: Operating Systems Winter Page Table Management, TLBs and Other Pragmatics. Gary Kimura

CSE 351. Virtual Memory

CSE 120 Principles of Operating Systems

CS 318 Principles of Operating Systems

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

Opera&ng Systems ECE344

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Address spaces and memory management

Virtual Memory. Virtual Memory

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1

Computer Systems. Virtual Memory. Han, Hwansoo

Virtual Memory. User memory model so far:! In reality they share the same memory space! Separate Instruction and Data memory!!

Memory Management - Demand Paging and Multi-level Page Tables

Virtual Memory. Physical Addressing. Problem 2: Capacity. Problem 1: Memory Management 11/20/15

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

Virtual Memory 2. q Handling bigger address spaces q Speeding translation

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

VIRTUAL MEMORY II. Jo, Heeseung

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

The memory of a program. Paging and Virtual Memory. Swapping. Paging. Physical to logical address mapping. Memory management: Review

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

VM as a cache for disk

Virtual Memory 1. Virtual Memory

Virtual Memory. Today. Segmentation Paging A good, if common example

Virtual Memory 1. Virtual Memory

Virtual Memory. Motivation:

Processes and Virtual Memory Concepts

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Virtual Memory. CS 3410 Computer System Organization & Programming

Virtual Memory #2 Feb. 21, 2018

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1

Multi-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis

Virtual Memory. CS 351: Systems Programming Michael Saelee

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1

1. Creates the illusion of an address space much larger than the physical memory

The Beast We Call A3. CS 161: Lecture 10 3/7/17

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Virtual to physical address translation

Computer Architecture. Lecture 8: Virtual Memory

Memory management, part 2: outline

Virtual Memory II CSE 351 Spring

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011

Virtual Memory: Concepts

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Modeling Page Replacement: Stack Algorithms. Design Issues for Paging Systems

Memory management OS

CS 537: Introduction to Operating Systems Fall 2015: Midterm Exam #1

Virtual Memory Design and Implementation

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program

CS152 Computer Architecture and Engineering. Lecture 15 Virtual Memory Dave Patterson. John Lazzaro. www-inst.eecs.berkeley.

Memory: Page Table Structure. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

The Virtual Memory Abstraction. Memory Management. Address spaces: Physical and Virtual. Address Translation

Virtual Memory. CS 3410 Computer System Organization & Programming. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

Basic Memory Management

MEMORY: SWAPPING. Shivaram Venkataraman CS 537, Spring 2019

VM Design and Tradeoffs

Move back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t

Memory Management Ch. 3

Memory Management. Goals of Memory Management. Mechanism. Policies

Exercises 6 - Virtual vs. Physical Memory, Cache

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Carnegie Mellon. 16 th Lecture, Mar. 20, Instructors: Todd C. Mowry & Anthony Rowe

Lecture 12: Demand Paging

CS 153 Design of Operating Systems Winter 2016

Transcription:

// Paging-Example-Question :5:57 paging-example-os6-question.txt A system implements paging using a page size of 96 (^) bytes. The diagram below shows the current state of the TLB, CoreMap, Swap Space and page tables for only two of several executing programs (Program A and Program B). Note that VPN refers to the virtual page number and PFN refers to the corresponding physical frame number. M, U, V, and D are the modified, use, valid and dirty bits, respectively. The SW entry (right most column in each page table) is used to denote the sector on the swap disk used to store the page. A value of - in the SW column indicates that the page is not stored on the swap disk. An X on the swap disk indicates that the sector is used. Assume that: o the next three potential victims chosen by the page replacement algorithm are (,, ); o the next three potential victims chosen by the TLB replacement algorithm are (,, ); o the next three potential free sectors used on the swap disk are (,, 5). List all steps performed by the operating system and MMU when executing the following sequence of memory references. Present the steps as a list of entries and distinguish those performed by the operating system (denote these with OS ) from those performed by the hardware (denote these with HW ). Be sure to include the resulting physical address if a valid translation is made. Process A does a load from address xc9a. Process A does a store to address xf8.

VPN TLB PFN V D CoreMap VPN PGM 5 5 Page Table A VPN PFN M U V D SW Page Table B VPN PFN M U V D SW A 7 B B B B 5 5 6 6 7 7 X X X 5 6 7 Swap Space

// :58:6 paging-example-os6-soln.txt We use pseudocode below in an attempt to keep the solution brief and hopefully clear. SW = software OS = operating system HW = hardware MMU = memory management unit PTA = page table for process A PTB = page table for process A VPN = virtual page number PFN = page frame number V = Valid bit M = Modified bit D = Dirty bit U = Use bit (can the page be dirtied) Process A does a load from address xc9a. The last bits of the virtual address correspond to the offset C9A, while the remaining bits indicate the page number. There is an entry with virtual page number (VPN) in the TLB, but it is invalid, which results in a TLB exception (Read Fault). BadVaddr = xc9a There is an entry with VPN in the page table of process A, PTA[].V == Note that if this was a store the kernel would kill the process because. PTA[].D == Frame is. PTA[].PFN == This information is copied in the TLB table in entry following the order (,,). TLB[].VPN = TLB[].PFN = TLB[].V = TLB[].D = If tracking use for page replacement, set the Use bit (U=) in the page table for A. PTA[].U =. The instruction is executed again with the new content of the TLB. This time there is is a valid TLB hit and the translation occurs. TLB[].VPN == and TLB[].V ==. If there were a Use bit (U) in the TLB it would get set by the MMU. TLB[].U = VPN is translated to PFN TLB[].PFN ==. The virtual address is directly translated to the physical address xc9a

. // :58:6 paging-example-os6-soln.txt Process A does a store to address xf8. The last bits of the virtual address correspond to the offset F8, while the remaining bits indicate the page number. TLB search for valid entry with virtual page number (VPN). Fails, so: TLB exception (Write Fault) BadVaddr = xf8 There is a valid entry with VPN in the page table of process A but it is invalid and indicates that the corresponding data is on sector of the swap partition. PTA[].V == PTA[].SW == This data needs to be loaded in memory (i.e., we have a page fault). The CoreMap indicates that there is no free frame in memory. As the page replacement algorithm replace pages (,,), page needs to be evicted. Victim =. The CoreMap indicates that page belongs to process B, with VPN. The page table of process B indicates that this page is modified (M=), so the corresponding data must be written to the swap partition, and that no sector of the swap partition has been allocated to this page yet. PTB[].V == PTB[].M == PTB[].SW == - As the next free sector are (,,5), the content of frame is written to sector of the swap partition. The Swap Space map is updated to indicate that Sector is used, the entry of the page table of process B is updated to set the Modified (M), Used (U) and Valid (V) bits to zero, and the SW entry to. SWAPMAP[] = X. PTB[].V == (not in memory anymore) PTB[].M == (we cleaned the page) PTB[].U == (clear for future) PTB[].SW == (where to get this page on the next fault)

// :58:6 paging-example-os6-soln.txt The content of sector of the swap partition is loaded into frame number. The corresponding entry in the CoreMap is updated to indicate that PFN corresponds to VPN of process A. Copy Sector from disk to Frame in memory. Coremap[].VPN = Coremap[].PGM = A Might actually just keep a pointer to the PTE for PTA[]. The entry of the page table of process A is updated by setting its valid (V) bit to (and setting/changing the PFN to, which it already was -- only coincidence). PTA[].V = PTA[].M = (Write Fault so page will get modified) PTA[].U = (Write Fault so page will get used) PTA[].SW (Could leave this alone in case it needs a spot again ) Or free it for someone else to use. The entry of the TLB is updated (since entry was updated in the previous question and the next replacement/choice is ) to indicate that VPN corresponds to PFN, setting the corresponding valid bit (V) to and dirty bit (D) to. TLB[].VPN = TLB[].PFN = TLB[].V = TLB[].D = The instruction is executed again, with the new contents of the TLB and the instruction succeeds. TLB[].VPN == and TLB[].V == If the MMU contains Modified (M) and Use (U) bits they are set to one in entry. TLB[].M = and TLB[].U = The virtual address is finally translated to the physical address xf8.