9.1 9.2 Indirection • Indirection means using one entity to _________________ • Examples: – A variable name vs. it's ____________________________ CS356 Unit 9 – _______________ vs. cell tower location/phone ID – Titles like "CEO" or "head coach" are virtual titles that can be applied to different people at different times • The benefits are we can change one without changing the Virtual Memory & Address other Translation – We can change the underlying implementation without changing the higher level task. For example, a job description would read "The CEO shall perform this duty or that." and it need not be changed if the company replaces John Doe with Jane Doe. • "All problems in computer science can be solved by another level of indirection" – attributed to David Wheeler 9.3 9.4 Benefits of Address Translation Virtual Memory & Address Translation • We are going to indirect the addresses used by computer programs • What is enabled through virtual memory and address • Primary Idea = Compile the program with __________________addresses translation? and have a _______________ convert these to physical addresses as the – Illusion of more or less memory than physically present program runs (this is Address Translation) – Efficiently ____________ the physical memory between several running – Isolation programs/processes and provide ________________ from accessing each – *Controlled sharing of code or data others' information • Secondary Idea = Use main memory (MM) as a "____________" for multiple – *Efficient I/O (memory-mapped files) programs' data as they run, using ________________________ as the home – *Dynamic allocation (Heap / Stack growth) location (this is Virtual Memory) – *Process migration – Remove the need of the programmer to know how much memory is physically present and/or give the illusion of ________________ physical memory than is • *Will be discussed in a subsequent unit or Operating present Systems class • These ideas are often used interchangeably
9.5 9.6 Memory Hierarchy & Caching Secondary Storage: Magnetic Disks • Magnetic hard drive consists of • Lower levels act as a cache for upper levels – Double sided surfaces/platters (with R/W head) – Each platter is divided into concentric tracks of small sectors that each store several thousand bits • Performance is slow primarily due to moving __________________ Registers L1 Cache ~ 1ns L1/L2 is a “cache” for L2 Cache main memory Read/Write Head 0 • Seek Time: Time needed to ______ ~ 10ns Read/Write Head 1 position the read-head above Surfaces … the proper track Main Memory • Rotational delay: Time needed ______ Virtual memory Read/Write Head 7 ~ 100 ns to bring the right sector under Sector 0 provides each the read-head Disk / Secondary Storage process its own • Depends on rotation Track 0 Sector 1 speed (e.g. 5400 RPM) ~1-10 ms address space in Track 1 • Transfer Time: 0.1 ms secondary storage • Disk Controller Overhead: + 2.0 ms and uses main ~20 ms Sector 2 memory as a cache This Photo by Unknown Author is licensed under CC BY-SA 9.7 9.8 Address Spaces Secondary Storage: Flash • Flash (_____________) drives store bits • Physical address spaces corresponds using special transistors that retain their to the actual system address ______ Program/Process values even when power is turned off 1,2,3,… (based on the ________ of the address bus) of the processor and • Performance is higher than magnetic 0xffff ffff - 0xffff ffff Not how much main memory is physically Mapped disks but still slower comparted to main used I/O present - memory 0xbfffffff • Each process/program runs in its own 0xc0000000 I/O Stack – Better sequential read throughput private "virtual" address space 0x80000000 - • HD (Magnetic): 122-204 MB/s – Virtual address space can be larger Heap Not • SSD: 210-270 MB/s (or smaller) than physical memory used - – MUCH better random read – Virtual address spaces are Data 0x10000000 0x3fffffff OS:PP 2 nd Ed. Fig. 12.6 - ____________ from each other • Max latency for single read/write: 75us Mem. Intel 710 SSD specs. • When many requests present we can overlap and Code 0x00000000 0x00000000 achieve latency of around 26us (1/38500) 32-bit Physical 32-bit Fictitious Virtual • Flash drives "____________" after Address Space w/ Address Spaces some number of writes/erasures only 1 GB of Mem ( > 1GB Mem)
9.9 9.10 Processes Virtual Address Spaces (VAS) Program/Process • Process • Virtual address spaces 0 - Code Program/Process 1,2,3,… 1 - Code – (def 1.) __________________________ 1,2,3,… (VASs) are broken into 0 - Code 2 - Data - 0xffff ffff • (Virtual) Address Space = Protected view of memory 1 - Code blocks called "________" 3 - Stack 0xffff ffff - Mapped 2 - Data • 1 or more threads 4 - Heap I/O 3 - Stack Mapped – (def 2.) : Running __________________ that has • Depending on the … I/O - 4 - Heap ___________________ 0xc0000000 - Stack program, much of the 0 0 0xc0000000 • Memory is protected: Address translation (VM) ensures no 1 Stack - 1 virtual address space will access to any other processes' memory 2 2 - Heap • I/O is protected: Processes execute in user-mode (not be __________ 3 3 Heap kernel mode) which generally means direct I/O access is - 0 Unalloc disallowed instead requiring system calls into the kernel Data • Pages can be allocated 1 - 0x10000000 … - Data • OS Kernel is not considered a "process" 2 0x10000000 "___________" (i.e. when - = Thread 0 – Has access to all resources and much of its code is Code the stack grows, etc.) 0x00000000 1 invoked under the execution of a user process thread Code 2 0x00000000 • All allocated pages can be Unalloc Address Spaces Unalloc stored in secondary … storage (hard drive) Secondary Used/Unused Blocks in Storage Virtual Address Space 9.11 9.12 Physical Address Space (PAS) Paging Phys. Addr. Space • Physical memory is broken into • Virtual address space is divided into equal 0 - Code 0xffffffff 1 - Code page-size blocks called "_______" size "pages" (often around 4KB) I/O 0 - Code 2 - Data and 0xffffffff 1 - Code • Multiple programs can be running • Physical memory is broken into page un- 3 - Stack I/O 2 - Data used and their pages can _______ the and 4 - Heap frames (which can hold any page of virtual area 3 - Stack un- … physical memory memory and then be swapped for another used 4 - Heap 0x3fffffff frame area 0 page) • Physical memory acts as a ______ 0 0-Code 0x3fffffff 1 frame 1 Pg. 0 for pages with secondary storage • Virtual address spaces can be __________ 2 0-Code 2 Pg. 2 acting as the backing store (next 3 while physical layout is not Pg. 0 3 2-Data 0 lower level in the hierarchy) Pg. 2 Unalloc Pg. 0 1 2-Data … Physical Frame of A page can be: • 2 Pg. 0 frame 0x00000000 memory can hold data from any virtual page. 0 – _______________ (not needed Since all pages are the Pg. 0 frame 0x00000000 Pg. 0 1 yet…stack/heap) same size any page can Pg. 1 Pg. 1 2 go in any frame (and be – Allocated and residing in secondary Pg. 2 Pg. 2 Unalloc 1GB Physical swapped at our desire). storage ( _____________ ) Pg. 3 unused Unalloc Memory and Secondary – Allocated and residing in main … unused unused 32-bit Address Storage memory ( ____________ ) … … Space Fictitious Virtual Proc. 1 VAS Proc. 2 VAS Address Spaces
Recommend
More recommend