PA1 due in one week TA office hour is 1-3 PM The grade would be available before that.

Slides:



Advertisements
Similar presentations
1 CMPT 300 Introduction to Operating Systems Virtual Memory Sample Questions.
Advertisements

16.317: Microprocessor System Design I
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
Lecture 7 Memory Management. Virtual Memory Approaches Time Sharing: one process uses RAM at a time Static Relocation: statically rewrite code before.
Chapter 19 Translation Lookaside Buffer Chien-Chung Shen CIS, UD
CS 5600 Computer Systems Lecture 7: Virtual Memory.
Lecture 8 Memory Management. Paging Too slow -> TLB Too big -> multi-level page table What if all that stuff does not fit into memory?
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Virtual Memory 2 P & H Chapter
CS 153 Design of Operating Systems Spring 2015
CS 153 Design of Operating Systems Spring 2015
Virtual Memory & Address Translation Vivek Pai Princeton University.
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Chapter 3.2 : Virtual Memory
CS 241 Section Week #12 (04/22/10).
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
1 Seoul National University Virtual Memory: Systems.
Virtual Memory CS Introduction to Operating Systems.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
A NEW PAGE TABLE FOR 64-BIT ADDRESS SPACES M. Talluri, M. D. Hill, Y. A. Kalidi University of Wisconsin, Madison Sun Microsystems Laboratories.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
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.
Chapter 18 Paging Chien-Chung Shen CIS, UD
Lecture 11 Page 1 CS 111 Online Memory Management: Paging and Virtual Memory CS 111 On-Line MS Program Operating Systems Peter Reiher.
PA0 due 60 hours. Lecture 4 Memory Management OSTEP Virtualization CPU: illusion of private CPU RAM: illusion of private memory Concurrency Persistence.
Address Translation. Recall from Last Time… Virtual addresses Physical addresses Translation table Data reads or writes (untranslated) Translation tables.
Chapter 21 Swapping: Mechanisms Chien-Chung Shen CIS, UD
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
Lecture 7 TLB. Virtual Memory Approaches Time Sharing Static Relocation Base Base+Bounds Segmentation Paging.
Lab4: Virtual Memory CS 3410 : Computer System Organization & Programming Spring 2015.
Address Translation Andy Wang Operating Systems COP 4610 / CGS 5765.
Address Translation Mark Stanovich Operating Systems COP 4610.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
CS203 – Advanced Computer Architecture Virtual Memory.
Chapter 18 Paging Chien-Chung Shen CIS/UD
Chapter 21 Swapping: Mechanisms Chien-Chung Shen CIS/UD
Chapter 20 Smaller Tables Chien-Chung Shen CIS, UD
Chapter 19 Translation Lookaside Buffer
CS161 – Design and Architecture of Computer
Paging Review Page tables store translations from virtual pages to physical frames Issues: Speed - TLBs Size – Multi-level page tables.
Review: Memory Virtualization
CS161 – Design and Architecture of Computer
Virtual Memory: the Page Table and Page Swapping
CSE 120 Principles of Operating
Lecture Topics: 11/19 Paging Page tables Memory protection, validation
CS703 - Advanced Operating Systems
Outline Paging Swapping and demand paging Virtual memory.
Paging COMP 755.
Christo Wilson Lecture 7: Virtual Memory
143A: Principles of Operating Systems Lecture 6: Address translation (Paging) Anton Burtsev October, 2017.
Memory Hierarchy Virtual Memory, Address Translation
PA1 is out Best by Feb , 10:00 pm Enjoy early
Paging Review: Virtual address spaces are broken into pages
CSCI206 - Computer Organization & Programming
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Lecture 6 Memory Management
Virtual Memory Hakim Weatherspoon CS 3410, Spring 2012
PA0 is due in 12 hours PA1 will be out in 12 hours
Virtual Memory Hardware
Christo Wilson Lecture 7: Virtual Memory
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Andy Wang Operating Systems COP 4610 / CGS 5765
Andy Wang Operating Systems COP 4610 / CGS 5765
Paging and Segmentation
Chapter 8: Main Memory CSS503 Systems Programming
CS 444/544 Operating Systems II Virtual Memory Translation
Presentation transcript:

PA1 due in one week TA office hour is 1-3 PM The grade would be available before that

Lecture 8 Memory Management

Virtual Memory Approaches Time Sharing Static Relocation Base Base+Bounds Segmentation Paging Too slow – TLB Too big – smaller tables

1 VPN = (VirtualAddress & VPN_MASK) >> SHIFT 2 (Success, TlbEntry) = TLB_Lookup(VPN) 3 if (Success == True) // TLB Hit 4 if (CanAccess(TlbEntry.ProtectBits) == True) 5 Offset = VirtualAddress & OFFSET_MASK 6 PhysAddr = (TlbEntry.PFN << SHIFT) | Offset 7 AccessMemory(PhysAddr) 8 else 9 RaiseException(PROTECTION_FAULT) 10 else // TLB Miss 11 PTEAddr = PTBR + (VPN * sizeof(PTE)) 12 PTE = AccessMemory(PTEAddr) 13 if (PTE.Valid == False) 14 RaiseException(SEGMENTATION_FAULT) 15 else if (CanAccess(PTE.ProtectBits) == False) 16 RaiseException(PROTECTION_FAULT) 17 else 18 TLB_Insert(VPN, PTE.PFN, PTE.ProtectBits) 19 RetryInstruction()

1 VPN = (VirtualAddress & VPN_MASK) >> SHIFT 2 (Success, TlbEntry) = TLB_Lookup(VPN) 3 if (Success == True) // TLB Hit 4 if (CanAccess(TlbEntry.ProtectBits) == True) 5 Offset = VirtualAddress & OFFSET_MASK 6 PhysAddr = (TlbEntry.PFN << SHIFT) | Offset 7 AccessMemory(PhysAddr) 8 else 9 RaiseException(PROTECTION_FAULT) 10 else // TLB Miss 11 RaiseException(TLB_MISS)

Context Switches What happens if a process uses the cached TLB entries from another process? Solutions? Flush TLB on each switch Remember which entries are for each process with address Space Identifier

How Many Physical Accesses Assume 256-byte pages, 16-bit addresses. Assume ASID of current process is 211 0xAA10: movl 0x1111, %edi 0xBB13: addl $0x3, %edi 0x0519: movl %edi, 0xFF10 the “prot” bits probably for the first TLB entry? why do two entries map to the same physical page, 0x91? which fields in the TLB would also appear in a PT? Do any have a different meaning? would access 0x0500 cause a segfault? validVPNPFNASIDProt 10xBB0x91211? 10xFF0x23211? 10x050x91112? 00x050x12211?

PTE Size Phys addr space contains 1024 pages. 7 bits needed for extras (prot, valid, etc.) Phys addrs 16-bits, pages are 32 bytes, 8 bits needed for extras Phys addr space is 4 GB, pages are 4 KB, 6 bits needed for extras

Page Table Size (a) PTE’s are 3 bytes, and there are 32 possible virtual page numbers (b) PTE’s are 3 bytes, virtual addrs are 24 bits, and pages are 16 bytes (c) PTE’s are 4 bytes, virtual addrs are 32 bits, and pages are 4 KB (d) PTE’s are 4 bytes, virtual addrs are 64 bits, and pages are 4 KB (e) assume each PTE is 10 bits. We cut the size of pages in half, keeping everything else fixed, including size of virt/phys addresses. By what factor does the PT increase in size?

Page Size (a) Goal PT size is 512 bytes. PTE’s are 4 bytes. Virtual addrs are 16 bits (b) Goal PT size is 1 KB. PTE’s are 4 bytes. Virtual addrs are 16 bits (c) Goal PT size is 4 KB. PTE’s are 4 bytes. Virtual addrs are 32 bits

Now let’s solve the too big problem

Motivation Why do we want big virtual address spaces? Programming is easier Applications need not worry (as much) about fragmentation Paging goals: Space efficiency (don’t waste on invalid data) Simplicity (no bookkeeping should require contiguous pages)

Change Sizes Make virtual address space smaller Make pages bigger PT size 512 bytes. PTE’s 4 bytes. Virtual addrs 16 bits PT size 1 KB. PTE’s 4 bytes. Virtual addrs 16 bits PT size 4 KB. PTE’s 4 bytes. Virtual addrs 32 bits Why are 4 MB pages bad? Internal fragmentation. Some systems support multiple page sizes Reduce TLB misses

Abandon Simple Linear Page Tables Use more complex PTs, instead of just a big array Look at the problem more closely..

Many invalid PT entries There is a big “hole” in our page table Invalid entries are clustered. How did we fix holes in physical memory before? Segmentation Paging

Approaches Change sizes Segments over PTs PTs over PTs PTs over PTs over PTs over PTs

Segmentation/Paging Hybrid Idea: use different page tables for heap, stack, etc Each PT can have a different size Each PT has a base/bounds (where?) Virtual address Before: PT_Index + OFFSET Now: SEG + PT_Index + OFFSET, VPN is SEG + PT_Index

Segment 00: code Segment 01: heap (a) 0x12FFF => (b) 0x10FFF => (c) 0x01ABC => (d) 0x11111 => PFNvalidProt 0x101r-x 0x151r-x 0x121r-x … PFNvalidProt 0x221rw- 0x021rw- 0x041rw- … 18-bit addresses. 2-bit segment index 6-bit VPN

Multi-Level Page Tables Idea: break PT itself into pages A page directory refers to pieces Only have pieces with >0 valid entries Used by x86 Virtual address Basic paging: PT_Index + OFFSET Segmentation/Paging: SEG + PT_Index + OFFSET Multi-level page tables: PD_Index + PT_Index + OFFSET

Next: finish multi-level page table and start swapping PA1 due in one week