CS 5204 Operating Systems Lecture 10

Slides:



Advertisements
Similar presentations
Paging Andrew Whitaker CSE451.
Advertisements

SE-292: High Performance Computing
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
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.
CS 153 Design of Operating Systems Spring 2015
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Translation Buffers (TLB’s)
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
CS 333 Introduction to Operating Systems Class 9 - Memory Management
Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more.
Memory Management April 28, 2000 Instructor: Gary Kimura.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Memory Management in Windows and Linux &. Windows Memory Management Virtual memory manager (VMM) –Executive component responsible for managing memory.
Paging. Memory Partitioning Troubles Fragmentation Need for compaction/swapping A process size is limited by the available physical memory Dynamic growth.
Cosc 3P92 Week 9 & 10 Lecture slides
CS333 Intro to Operating Systems Jonathan Walpole.
Computer Architecture Lecture 28 Fasih ur Rehman.
CS 3204 Operating Systems Godmar Back Lecture 11.
CS 4284 Systems Capstone Godmar Back Virtual Memory – Page Tables.
Operating Systems ECE344 Ding Yuan Paging Lecture 8: Paging.
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
CS 3204 Operating Systems Godmar Back Lecture 15.
Chapter 4 Memory Management Virtual Memory.
CS399 New Beginnings Jonathan Walpole. Virtual Memory (1)
Virtual Memory Part 1 Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology May 2, 2012L22-1
Processes and Virtual Memory
1 Pintos Virtual Memory Management Project (CS3204 Spring 2006 VT) Yi Ma.
Protection of Processes Security and privacy of data is challenging currently. Protecting information – Not limited to hardware. – Depends on innovation.
CS 3204 Operating Systems Godmar Back Lecture 16.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
CS203 – Advanced Computer Architecture Virtual Memory.
CS161 – Design and Architecture of Computer
Translation Lookaside Buffer
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Virtual Memory CSSE 332 Operating Systems
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Session 3 Memory Management
Lecture Topics: 11/19 Paging Page tables Memory protection, validation
Virtual Memory – Page Tables
Page Table Implementation
CS 5204 Operating Systems Linking and Loading Godmar Back.
Memory Hierarchy Virtual Memory, Address Translation
CS510 Operating System Foundations
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Page Replacement.
CS 4284 Systems Capstone Linking and Loading Godmar Back.
CS399 New Beginnings Jonathan Walpole.
Translation Lookaside Buffer
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE451 Virtual Memory Paging Autumn 2002
Translation Buffers (TLB’s)
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Lecture 8: Efficient Address Translation
CSE 471 Autumn 1998 Virtual memory
Translation Lookaside Buffers
Paging and Segmentation
CSE 451: Operating Systems Lecture 10 Paging & TLBs
CS703 - Advanced Operating Systems
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
Translation Buffers (TLBs)
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.
Review What are the advantages/disadvantages of pages versus segments?
Paging Andrew Whitaker CSE451.
Presentation transcript:

CS 5204 Operating Systems Lecture 10 Godmar Back

Announcements This week: first milestone meeting Sign up now Reports due by 5pm today Midterm will be handed back next Monday (Oct 31) Might switch some presentations - will update reading list and send email to affected presenters Move up SFI (John) & Nooks (Hari) CS 5204 Fall 2005 1/2/2019

Plan for Today End-to-End argument Review memory management CS 5204 Fall 2005 1/2/2019

Layered Architectures (horizontal component) Layer k may interact with peer layer k only via protocols (vertical component) Layer k+1 interacts with layer k via interface CS 5204 Fall 2005 1/2/2019

Layering and the E2E Argument Physical Datalink Network Transport Session Presentation Application In any system using layering, designer has a choice of where to place functionality Unless design by committee CS 5204 Fall 2005 1/2/2019

End-to-end argument If correct & complete implementation requires help & knowledge only endpoints have, do not push the functionality down into lower layers Corollary: A layer should only implement functionality that is needed by all clients, and can be completely implemented within that layer. CS 5204 Fall 2005 1/2/2019

E2E Examples Careful file transfer Security & Encryption Error detection & correction Causal message delivery CS 5204 Fall 2005 1/2/2019

E2E (cont’d) Note that endpoint != application Endpoint can also be a layer How to identify the endpoints? Reasons for violating E2E: Performance Cost Software engineering/Code Reuse (?) E2E is only a guiding principle, a type of “Occam’s Razor” CS 5204 Fall 2005 1/2/2019

Review Memory Management Logical Organization Physical Organization Protection Paging CS 5204 Fall 2005 1/2/2019

Logical Organization MAX_USER Stack Heap Data Code/Text  Local  Dynamic Heap Data  Global/Static Code/Text CS 5204 Fall 2005 1/2/2019

Compilation and Memory Layout hello.decaf: void main() { Print(“Hello”); } hello.o Linker Stack Decaf Compiler ELF executable: hello.s: tmp: .asciz “Hello”; Loader data hello\0 Heap text Data Assembler Code/Text CS 5204 Fall 2005 1/2/2019

Quick Demo of /proc/*/maps CS 5204 Fall 2005 1/2/2019

Linux IA32 3+1 Model 4GB Kernel Stack MAX_USER =3GB Heap Data  Local  Dynamic Heap Data  Global/Static Code/Text CS 5204 Fall 2005 1/2/2019

Linux IA32 3+1 Model (MT) 4GB Kernel MAX_USER =3GB Heap Data Code/Text Stack 1  Local Stack 2  Dynamic Heap Data  Global/Static Code/Text CS 5204 Fall 2005 1/2/2019

Virtual Address Space Management Key resource is virtual addresses Memory objects occupy continuous regions: Stacks of kernel threads Data segment Shared libraries: Data, bss, text Subtract space taken up by kernel if necessary 64bit architectures where sizeof (void*) == 8 this is practically no longer an issue But tough on 32bit architectures CS 5204 Fall 2005 1/2/2019

Virtual to Physical Mapping Virtual Memory Addresses Physical Memory Addresses MMU Virt_max: 0…2^sizeof(void*) Phys_max: 0…RAMsize Page Table: V → P CS 5204 Fall 2005 1/2/2019

OS Tasks for Virtual Memory Mgnt Predominant technology today: Paging Older technique: segmentation Must maintain & update permissions for each page (Protection) Must maintain & update VirtPhys mappings and adjust on context switch Must manage physical frames Detect usage & store content of unused frames to secondary storage CS 5204 Fall 2005 1/2/2019

Protection Memory is associated with protection bits: R – Read W – Write X – Execute U – User – can it be accessed in user mode Oddball X86: pages only have “W” write bit + U bit. Recent addition “NX” bit – “don’t execute” Note: OS has full control over what a virtual address resolves to for a given process Trap is caused if it doesn’t resolve to anything at the moment Trap is caused if permissions don’t allow attempted action CS 5204 Fall 2005 1/2/2019

Maintaining V  P Mappings Note that V  P translation happens on every memory access Caching needed  cache is called TLB (“translation lookaside buffer”) What happens on a TLB miss? TLB misses can be handled in software or hardware: Software: special handler must look up mapping and restore it (MIPS, Alpha) Hardware: (x86) must follow data structure layout in memory so MMU can read information from there to refill TLB CS 5204 Fall 2005 1/2/2019

x86 Virtual Address Translation Pre-PAE x86 Microsoft Technet [URL] CS 5204 Fall 2005 1/2/2019

Linux Page Table Structure PAE x86 shown: from two-level to three-level translation scheme (2+9+9+12 vs 10+10+12) Source: Mel Gorman: Understanding the Linux Virtual Memory Manager Linux’s internal structures mimic what MMU expects Ports to other architectures must emulate x86 page tables in Linux kernel CS 5204 Fall 2005 1/2/2019

TLB & Context Switches Note that mappings are process-specific: Virtual address 10000 in process A maps to a different page then address 10000 in process B – every process gets it own address space Either tag TLB entries with process id (MIPS) or flush entire TLB on context switch (x86) The subsequent TLB misses are what makes a context switch expensive. CS 5204 Fall 2005 1/2/2019

Managing Physical Frames Now memory is viewed as a resource Must keep track of what’s free, what’s in use Buddy allocator Must keep track of what’s stored in pages that are in use Consumers are memory objects User process objects (stacks, data, text, …) In-kernel ones (file system buffer caches, packet buffers, etc.) Algorithms Idea: monitor how pages are accessed, write least used ones to disk LRU heuristics, page buffering CS 5204 Fall 2005 1/2/2019

Summary Memory Management involves Logical organization of address space Physical organization of memory Policies for protection (page-based, traditionally) Policies for paging CS 5204 Fall 2005 1/2/2019