12 Pages

vm

Course: CPS 110, Fall 2009
School: Duke
Rating:
 
 
 
 
 

Word Count: 1652

Document Preview

Memory Virtual and Demand Paging Virtual Memory Illustrated executable file header text idata data wdata symbol table, etc. program sections virtual memory (big) text data BSS user stack args/env kernel physical memory (small) backing storage pageout/eviction page fetch process segments physical page frames virtual-to-physical translations 1 Virtual Address Translation 29 virtual address VPN Example:...

Register Now

Unformatted Document Excerpt

Coursehero >> North Carolina >> Duke >> CPS 110

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Memory Virtual and Demand Paging Virtual Memory Illustrated executable file header text idata data wdata symbol table, etc. program sections virtual memory (big) text data BSS user stack args/env kernel physical memory (small) backing storage pageout/eviction page fetch process segments physical page frames virtual-to-physical translations 1 Virtual Address Translation 29 virtual address VPN Example: typical 32-bit architecture with 8KB pages. Virtual address translation maps a virtual page number (VPN) to a physical page frame number (PFN): the rest is easy. Deliver exception to OS if translation is not valid and accessible in requested mode. physical address 13 0 00 offset address translation { PFN + offset Role of MMU Hardware and OS VM address translation must be very cheap (on average). Every instruction includes one or two memory references. (including the reference to the instruction itself) VM translation is supported in hardware by a Memory Management Unit or MMU. The addressing model is defined by the CPU architecture. The MMU itself is an integral part of the CPU. The role of the OS is to install the virtual-physical mapping and intervene if the MMU reports that it cannot complete the translation. 2 The Translation Lookaside Buffer (TLB) An on-chip hardware translation buffer (TB or TLB) caches recently used virtual-physical translations (ptes). Alpha 21164: 48-entry fully associative TLB. A CPU pipeline stage probes the TLB to complete over 99% of address translations in a single cycle. Like other memory system caches, replacement of TLB entries is simple and controlled by hardware. e.g., Not Last Used If a translation misses in the TLB, the entry must be fetched by accessing the page table(s) in memory. cost: 10-200 cycles A View of the MMU and the TLB CPU TLB Control MMU Memory 3 Completing a VM Reference start here probe page table load TLB MMU access physical memory probe TLB access valid? raise exception load TLB zero-fill OS allocate frame page fault? signal process fetch from disk page on disk? The OS Directs the MMU The OS controls the operation of the MMU to select: (1) the subset of possible virtual addresses that are valid for each process (the process virtual address space); (2) the physical translations for those virtual addresses; (3) the modes of permissible access to those virtual addresses; read/write/execute (4) the specific set of translations in effect at any instant. need rapid context switch from one address space to another MMU completes a reference only if the OS says its OK. MMU raises an exception if the reference is not OK. 4 Alpha Page Tables (Forward Mapped) 21 seg 0/1 base + + + L1 10 L2 10 L3 PO 10 13 sparse 64-bit address space (43 bits in 21064 and 21164) offset at each level is determined by specific bits in VA PFN three-level page table (forward-mapped) A Page Table Entry (PTE) This is (roughly) what a MIPS/Nachos page table entry (pte) looks like. valid bit: OS uses this bit to tell the MMU if the translation is valid. write-enable: OS touches this to enable or disable write access for this mapping. PFN dirty bit: MMU sets this when a store is completed to the page (page is modified). reference bit: MMU sets this when a reference is made through the mapping. 5 Paged Virtual Memory Like the file system, the paging system manages physical memory as a page cache over a larger virtual store. Pages not resident in memory can be zero-filled or found somewhere on secondary storage. MMU and TLB handle references to resident pages. A reference to a non-resident page causes the MMU to raise a page fault exception to the OS kernel. Page fault handler validates access and services the fault. Returns by restarting the faulting instruction. Page faults are (mostly) transparent to the interrupted code. Care and Feeding of TLBs The OS kernel carries out its memory management functions by issuing privileged operations on the MMU. Choice 1: OS maintains page tables examined by the MMU. MMU loads TLB autonomously on each TLB miss page table format is defined by the architecture OS loads page table bases and lengths into privileged memory management registers on each context switch. Choice 2: OS controls the TLB directly. MMU raises exception if the needed pte is not in the TLB. Exception handler loads the missing pte by reading data structures in memory (software-loaded TLB). 6 Where Pages Come From file volume with executable programs text data BSS user stack args/env Modified (dirty) pages are pushed to backing store (swap) on eviction. Fetches for clean text or data are typically fill-from-file. kernel Paged-out pages are fetched from backing store when needed. Initial references to user stack and BSS are satisfied by zero-fill on demand. Demand Paging and Page Faults OS may leave some virtual-physical translations unspecified. mark the pte for a virtual page as invalid If an unmapped page is referenced, the machine passes control to the kernel exception handler (page fault). passes faulting virtual address and attempted access mode Handler initializes a page frame, updates pte, restarts. If and a disk access is required, the OS may switch to another process after initiating the I/O. Page faults are delivered at IPL 0, just like a system call trap. Fault handler executes in context of faulted process, blocks on a semaphore or condition variable awaiting I/O completion. 7 Issues for Paged Memory Management The OS tries to minimize page fault costs incurred by all processes, balancing fairness, system throughput, etc. (1) fetch policy: When are pages brought into memory? prepaging: reduce page faults by bring pages in before needed clustering: reduce seeks on backing storage (2) replacement policy: How and when does the system select victim pages to be evicted/discarded from memory? (3) backing storage policy: Where does the system store evicted pages? When is the backing storage allocated? When does the system write modified pages to backing store? Where Pages Come From file volume with executable programs text data BSS user stack args/env Modified (dirty) pages are pushed to backing store (swap) on eviction. Fetches for clean text or data are typically fill-from-file. kernel Paged-out pages are fetched from backing store when needed. Initial references to user stack and BSS are satisfied by zero-fill on demand. 8 Questions for Paged Virtual Memory 1. How do we prevent users from accessing protected data? 2. If a page is in memory, how do we find it? Address translation must be fast. 3. If a page is not in memory, how do we find it? 4. When is a page brought into memory? 5. If a page is brought into memory, where do we put it? 6. If a page is evicted from memory, where do we put it? 7. How do we decide which pages to evict from memory? Page replacement policy should minimize overall I/O. VM Internals: Mach/BSD Example address space (task) start, len, prot start, len, prot start, len, prot start, len, prot vm_map lookup enter memory objects putpage getpage pmap pmap_enter() pmap_remove() One pmap (physical map) per virtual address space. pmap_page_protect pmap_clear_modify pmap_is_modified pmap_is_referenced pmap_clear_reference page cells (vm_page_t) array indexed by PFN page table system-wide phys-virtual map 9 Mapped Files With appropriate support, virtual memory is a useful basis for accessing file storage (vnodes). bind file to a region of virtual memory with mmap syscall. e.g., start address x virtual address x+n maps to offset n of the file several advantages over stream file access uniform access for files and memory (just use pointers) performance: zero-copy reads and writes for low-overhead I/O but: program has less control over data movement style does not generalize to pipes, sockets, terminal I/O, etc. Using File Mapping to Build a VAS executable image header text idata data wdata symbol table relocation records Memory-mapped files are used internally for demand-paged text and initialized static data. text data text data segments sections header text idata data wdata symbol table relocation records loader BSS user stack args/env kernel u-area library (DLL) BSS and user stack are anonymou...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Duke - CPS - 100
What is Computer Science?What is it that distinguishes it from the separate subjects with which it is related? What is the linking thread which gathers these disparate branches into a single discipline? My answer to these questions is simple - it is
Duke - CPS - 100
Review of Data StructuresADTs: Abstract Data TypesWe've studied concrete data structures Vectors Homogeneous aggregates supporting random accessLinked lists Collections supporting constant-time insertionMultiset is an ADT Operations toget
Duke - CPS - 100
ADTs and vectors, towards linked listslLinked listslltvector is a class-based implementation of a lower-level data type called an array tvector grows dynamically (doubles in size as needed) when elements inserted with push_back tvector prot
Duke - CPS - 100
Graphs: Structures and AlgorithmslVocabularylHow do packets of bits/information get routed on the internet Message divided into packets on client (your) machine Packets sent out using routing tables toward destination Packets may take differ
CUNY Baruch - CIS - 718
NURUNNAHER SHIKHA CIS 718 EXPERT SYSTEM HW 1, DATE:10.25.05ACM Turing Award1966 A.J. Perlis Influence in the area of advanced programming techniques and compiler construction. 1967 Maurice V. Wilkes Known as the builder and designer of the EDSAC,
CUNY Baruch - CIS - 718
ACM Turing Award Recipients List Summary: Yuhang Jiang mike.jiang@gmail.com CIS718, 11/1/2005Yuhang Jiang CIS718, 11/1/2005 ACM Turing Award Summary: Award Winner Year Main Contribution A.J. Perlis 1966 advanced programming techniques and compiler
CUNY Baruch - CIS - 718
The Use of Expert Systems in Conservation Author: Lida Liberopoulou Introduction This project was the MSc Thesis for a Computing Science cource at Birkbeck College, London and was presented at the 1999 AI*IA "Intelligenza Artificiale per i Beni Cu
CUNY Baruch - CIS - 718
Sevda Mammadova Prof. D. Kopec2238 CIS 718SmartLaw: Adapting Classic Expert System Techniques For the Legal Research DomainSmartLaw is an Expert System that gives advice on legal research problems. It uses four level knowledge structure of rese
Duke - CPS - 108
Standard C Library Functions tmpnam(3C)NAME tmpnam, tmpnam_r, tempnam - create a name for a temporary fileSYNOPSIS #include <stdio.h> char *tmpnam(char *s); char *tmpnam_r(char *s);
CUNY Baruch - CC - 312
-BEGIN PGP PUBLIC KEY BLOCK-Version: PGP 8.1 - not licensed for commercial use: www.pgp.commQGiBEOQg8YRBADEU5fQHDlqNe6lE8Npyee8zu0CZt9nHUUZJ3L/fR4/4GYogk6ooB9xwLeypQ1oBUAWCIoqZFYaxE5+yCaBYW8xb5WSFJINJoA0qbPwlWXdLbGmwIKD/ebXaKHuwSqCuFnhaJ4WlhAjk7
CUNY Baruch - CS - 1007
CS1007 lecture #20 notestue 19 nov 2002 news streams files java.io package exceptions StringTokenizer formatting output reading: ch 10-11cs1007-fall2002-sklar-lect20 1streams (1).we've drawn a picture of input and output many
CUNY Baruch - CS - 1007
CS1007 lecture #5 notestue 17 sep 2002 news boolean expressions logical operators truth tables relational operators the if branching statement owcharts command line arguments System.exit() method reading: ch 3.1-3.4cs1007-fall2002-sklar-lect05
CUNY Baruch - CS - 1007
last time in cs1007.course objectives policies academic integrity resources WEB PAGE: http:/www.columbia.edu/cs1007 NOTE CHANGES IN ASSESSMENT 5 EXTRA CREDIT POINTS ADDEDcs1007-fall2002-sklar-lect02 1recitations.sign up for a recitatio
CUNY Baruch - CS - 3157
write(2)write(2)NAMEwrite, pwrite, writev - write on a fileSYNOPSIS#include <unistd.h> ssize_t write(int fildes, const void *buf , size_t nbyte); #include <sys/types.h> #include <unistd.h> ssize_t pwrite(int fildes, const void *buf , size_t n
CUNY Baruch - CS - 1007
CS1007 lecture #12 notestue 15 oct 2002 news objects classes constants methods (review) encapsulation and visibility (the public and private modifiers) instantiation (the static modifier) reading: ch 6.1-6.7cs1007-spring2002-sklar-lect12
CUNY Baruch - CS - 1007
CS1007 lecture #8 notesthu 26 sep 2002 news homework #2 due tue oct 1 homework #1 should be returned in recitation this week short quiz #1 today the java.util.Random class the java.util.Date class introduction to recursion method overloading read
Duke - CPS - 100
Balanced Search TreesBinary search trees keep keys ordered, with efficient lookup Insert, Delete, Find, all are O(log n) in average case Worst case is bad Compared to hashing? Advantages? Balanced trees are guaranteed O(log n) in the worst case
Duke - CPS - 150
cps150, Fall 2001homework-5Due Date: 1. Written Part Due on 11/02, Friday, in class. 2. Programming Part Due on 11/02, Friday, midnight. (Be aware that every problem involve implementation in Matlab). Part I: Sensitivity to perturbation We consid
Duke - CPS - 230
11AWw5f11IwXW1 ~1Y11A1A~wXw1 X11~kA1k`w17XwWA11`Xww05!1! X YXF Qc4baIVP HX E~w141I` XyefYXWAXw1 3V1UTTT5Q43HGw1W5#F1w1! ` # F FRSSSRP I F D
Duke - CPS - 216
Eddies: Continuously Adaptive Query Processingby Ron Avnur and Joseph M. HellersteinIntroductionLarge-scale query engines (WANs, clusters) must be able to perform robustly under changing conditions Telegraph is a system being developed to provide
Duke - CPS - 216
CPS 216 Fall 2001 Course Project Important Dates Milestone 1: Thursday, October 18 Milestone 2: Thursday, November 15 Project Demo and Presentation Period: December 3-7, 10-12 Final Project Report Due: Thursday, December 13 You can choose either one
Duke - CPS - 100
Balanced Search TreesqqBinary search trees keep keys ordered, with efficient lookup Insert, Delete, Find, all are O(log n) in average case Worst case is bad Compared to hashing? Advantages? Balanced trees are guaranteed O(log n) in the worst
Duke - CPS - 100
Efficient ProgrammingqSee readwords.cppqDesigning and building efficient programs efficiently requires knowledge and practice Hopefully the programming language helps, it's not intended to get in the way Object-oriented concepts, and more gen
Duke - CPS - 100
Sorting: From Theory to PracticeqWhy do we study sorting? Because we have to Because sorting is beautiful Because and There are n sorting algorithms, how many should we study? O(n), O(log n), Why do we study more than one algorithm? q
Duke - CPS - 100
Graphs: Structures and AlgorithmsHow do packets of bits/information get routed on the internet Message divided into packets on client (your) machine Packets sent out using routing tables toward destination Packets may take different routes to des
Duke - CPS - 100
CPS 100E - Program Design and Analysis I Prof. Rodger Section: Templates, Stacks, Queues handout Read W3, W6.1-6.3, W15, W11Overloading FunctionsFunctions can have the same name if they have di erent arguments. This is called overloading. When the
Duke - CPS - 100
CPS 100E - Program Design and Analysis I Prof. Rodger Section: Vectors in classes, Pointers handout Read A8.4, A12.1-12.3, W1 A class declaration does not create any memory. When variables of that type of class are de ned using the constructor then m
Duke - CPS - 100
CPS 100E - Program Design and Analysis I Prof. Rodger Section: Balanced Trees and Hu man Coding handout Read Chap 12.1Balanced TreesAVL Trees 2-3 trees, B-trees Red-Black TreeRed-Black TreeBinary search tree properties every node is red or blac
BYU - CATALOG - 0406
Programs of Study and Course DescriptionsFollowing is a list of undergraduate courses and programs for Stern College for Women and Sy Syms School of Business. Unless otherwise noted, courses meet for the same number of hours per week as the credit v
Duke - CPS - 100
From bits to bytes to intsHow are data stored?At some level everything is stored as either a zero or a one A bit is a binary digit a byte is a binary term (8 bits) We should be grateful we can deal with Strings rather than sequences of 0's
Duke - CPS - 100
Intro to GraphsDefinitions and VocabularyA graph consists of a set of vertices (or nodes) and a set of edges (or arcs) where each edge connects a pair of vertices. If the pair of vertices defining an edge is ordered, then it is a directed graph.
Duke - CPS - 100
Binary TreesLinked lists: efficient insertion/deletion, inefficient search ArrayList: search can be efficient, insertion/deletion not Binary trees: efficient insertion, deletion, and search trees used in many contexts, not just for searching, e.g.
Duke - CPS - 100
Graphical User Interfaces (GUIs) Components Flat Layouts Hierarchical Layouts Designing a GUI Coding a GUI(These notes come from CompSci 4, Java for Video Games)CompSci 100E30.1Components JLabel text/image display JTextField sin
Duke - CPS - 100
Inheritance and Interfaces Single inheritance in JavaInheritance models an "is-a" relationshipA class can extend only one class in Java A dog is a mammal, an ArrayList is a List, a square is a shape, Write general programs to understand
Duke - CPS - 100
Java 5 New Features Generics Generics Enhanced for loop Autoboxing/unboxing Typesafe enums Other Allows classes to store objects whose type is irrelevant to storing class, while allowing type-safe retrieval E.g., Collection SyntaxArr
Duke - CPS - 100
Binary TreesFrom doubly-linked lists to binary treesLinked lists: efficient insertion/deletion, inefficient search ArrayList: search can be efficient, insertion/deletion not Binary trees: efficient insertion, deletion, and search trees used i
Duke - CPS - 100
Balanced Binary Search TreesBalanced Binary Search TreesPathological BST Keeping BSTrees Balanced Insert nodes from ordered list Search: O(_) ? Binary Tree is balanced if height of left and right subtree differ by no more than one, recurs
BYU - CATALOG - 0204
Sy Syms School of Businessy Syms School of Business offers business programs for undergraduate men and women. It was established in 1987 through major gifts by Sy Syms, a member of the Universitys Board of Trustees, and other business leaders. The S
BYU - CATALOG - 0204
Irving I.Stone Beit Midrash ProgramEstablished in 1995, the Irving I. Stone Beit Midrash Program offers undergraduate men a structured Jewish studies program designed for students with special scheduling needs and interests. It maintains a high l
Duke - CPS - 100
Data and InformationOrganizing Data: ideas and issues!How and why do we organize data? Differences between data and information? What about knowledge?!Often there is a time/space tradeoff ! If we use more space (memory) we can solve a data/ i
Duke - CPS - 100
Loop Invariants!Bean Can game! !!Want to reason about the correctness of a proposed iterative solution Loop invariants provide a means to effectively about the correctness of codeCan contains N black beans and M white beans initially Emptie
Duke - CPS - 108
LibrariesqIn C+ it's possible to create static libraries and shared libraries Static libraries (end in .a) are combined/linked into an executable Executables are large. If library is updated in a binary compatible way, programs still need to be
Duke - CPS - 108
Overloading operatorsqWhy overload operators? (=, =, <, >, +=, ) notational convenience match user expectations because we can (except : and . and .*) Remember, overloaded operators are just function calls operands are parameters, thus subject
Duke - CPS - 108
Software DesignSee Alan Cooper, The Essentials of User Interface Design q who designs the software?Implentation modelworsebetterusers modelqqImplementation is view of software developer, users view is mental model, software designer ha
Duke - CPS - 100
Backtracking, Search, HeuristicsqClassic problem: N queensqMany problems require an approach similar to solving a maze Certain mazes can be solved using the "right-hand" rule Other mazes, e.g., with islands, require another approach If you h
Duke - CPS - 100
Heaps, Priority Queues, CompressionqPriority QueueqCompression is a high-profile application .zip, .mp3, .jpg, .gif, .gz, Why is compression important? Whats the difference between compression for .mp3 files and compression for .zip files?
Duke - CPS - 100
cps 100 "Green I do not Lack" as sung to the tune of Sir-mix alot's " Baby's got back" Intro-oh my god, Joey look at this apt it is so big uhh it looks like one of those big time programs but u know who understands those programs they only work becau
Duke - CPS - 140
CPS 140Project 3 Project Due: Saturday, April 24, 8am 50 pointsSpring 1999No LATE projects accepted after Thursday, April 29, 8am.The purpose of this assignment is to write an interpretor for the LSYS programming language see the project 1 and
Duke - CPS - 140
Section: Turing Machines Review Regular Languages FA, RG, RE recognize Context Free Languages PDA, CFG recognize1DFA:input tape a tape head current state 0 5 4 3 1 2 b b a bhead moves2Turing Machine:input tape a tape head current state
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: The Structure of a Compiler 1.1 What is a Compiler? I. Translator Definition: program in language X - translator for X - program in language YExamples: Source Language High Level Assem
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: Transforming Grammars Ch. 6 handoutMethods for Transforming Grammars Read Ch 6 in Linz BookWe will consider CFL without . It would be easy to add to any grammar by adding a new start
Duke - CPS - 140
Section: Turing Machines - Building Blocks 1. Given Turing Machines M1 and M2 Notation for Run M1 Run M2M1 M2SHSHM1M2SHz;z,Rz;z,LSHz represents any symbol in12. Given Turing Machines M1 and M2M1 M2SHSHM1x
Duke - CPS - 140
Grammars unrestricted grammarAutomata Turing machineAll Languages Rec. Enum. Lang.CFGContext-free Lang. Regular Lang.pushdown automataregular grammarfinite automata1Power of Machines automata Can do? FA PDA TM integers arith exprC
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. Susan Rodger Section: Introduction Ch. 1 handoutgrammarsall languagesautomataunrestricted grammarrecursively enumerable languagesTuring machineCFGcontext-free languages regular languagesp
Duke - CPS - 140
CPS 140Project 2 Due: Tuesday, March 25 50 pointsSpring 2003The purpose of this assignment is to write a parser for the SAPL programming language (see the project 1 handout for a description of the tokens in the SAPL programming language). Your
Duke - CPS - 140
Section: Recursively Enumerable Languages1Denition: A language L is recursively enumerable if there exists a TM M such that L=L(M).recursively enumerable languages context-free languages regular languagesDenition: A language L is recursive if
Duke - CPS - 140
Section: Pushdown Automata Ch. 7 - Pushdown Automata A DFA=(Q,q0,F)input tape a a tape head b b a b head movescurrent state 0 11Modify DFA by adding a stack. New machine is called Pushdown Automata (PDA).input tapeaa tape headaabb
Duke - CPS - 140
Section: Properties of Regular Languages Example L = {anban | n > 0}Closure Properties A set is closed over an operation if L1, L2 class L1 op L2 = L3 L3 class1L1={x | x is a positive even integer} L is closed under addition? multiplication?
Duke - CPS - 140
CPS 140Homework 5 Due: Tuesday, Mar. 30 22 pointsSpring 1999On homework, you may discuss with other students in the course about how to solve a problem, but the write-up should be your own. You must include the names of any students you consult
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: The Structure of a Compiler 1.1 What is a Compiler? I. Translator Definition: program in translator program in language - for - language X X Y1Examples: Source Object Language Langua
Duke - CPS - 140
CPS 140Lab 2 Due: Thursday, March. 25, 8pm 20 pointsSpring 1999Problem:Using JFLAP, construct pushdown automata for the following languages. NOTE: If you have problems typing Z in the labels, then instead use little z and push it onto the stac