Operating Systems, 371-1-1631 Winter Semester 2011 Practical Session 9, Memory 1.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Practical Session 9, Memory
Page Table Implementation
1 CMPT 300 Introduction to Operating Systems Virtual Memory Sample Questions.
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
16.317: Microprocessor System Design I
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Memory Management (II)
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Multiprocessing Memory Management
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
Memory Management.
Chapter 3.2 : Virtual Memory
Chapter 7: Main Memory CS 170, Fall Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
Virtual Memory I Chapter 8.
1 Tuesday, July 04, 2006 "Programs expand to fill the memory available to hold them." - Modified Parkinson’s Law.
CS 241 Section Week #12 (04/22/10).
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Chapter VIII Virtual Memory Review Questions Jehan-François Pâris
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Operating Systems, 132 Practical Session 9, Memory 1.
Chapter 8 Memory Management Dr. Yingwu Zhu. Outline Background Basic Concepts Memory Allocation.
Computer Architecture Lecture 28 Fasih ur Rehman.
OSes: 8. Mem. Mgmt. 1 Operating Systems v Objectives –describe some of the memory management schemes used by an OS so that several processes can be in.
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 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 34 Paging Implementation.
Operating Systems COMP 4850/CISG 5550 Page Tables TLBs Inverted Page Tables Dr. James Money.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
© 2004, D. J. Foreman 1 Virtual Memory. © 2004, D. J. Foreman 2 Objectives  Avoid copy/restore entire address space  Avoid unusable holes in memory.
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
Virtual Memory 1 1.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Chapter 91 Logical Address in Paging  Page size always chosen as a power of 2.  Example: if 16 bit addresses are used and page size = 1K, we need 10.
Operating Systems Unit 7: – Virtual Memory organization Operating Systems.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
Page Table Implementation. Readings r Silbershatz et al:
CHAPTER 3-3: PAGE MAPPING MEMORY MANAGEMENT. VIRTUAL MEMORY Key Idea Disassociate addresses referenced in a running process from addresses available in.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
Operating Systems Practical Session 8, Memory 1. Quick recap - Swapping Swapping basically means we bring the entire process to memory, use it, and possibly.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Memory Management & Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
Memory: Page Table Structure CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Memory: Page Table Structure
Memory Management Virtual Memory.
Virtual Memory Chapter 7.4.
Memory COMPUTER ARCHITECTURE
Virtual Memory - Part II
Practical Session 9, Memory
Chapter 8: Main Memory.
CSCI206 - Computer Organization & Programming
Operating System Concepts
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Lecture 29: Virtual Memory-Address Translation
CPSC 457 Operating Systems
Virtual Memory Hardware
Practical Session 9, Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
4.3 Virtual Memory.
Virtual Memory 1 1.
Presentation transcript:

Operating Systems, Winter Semester 2011 Practical Session 9, Memory 1

Quick recap - Swapping Swapping basically means we bring the entire process to memory, use it, and possibly put it back to our store (e.g. large enough disk). Swap time proportional to the amount of swapped memory – a heavy operation. Creates holes in memory. Hardly used anymore… 2

Quick recap – Paging and Virtual Memory What happens when the process’s memory requirements are too large to fit into the physical memory? Only part of the program reside in the memory while the rest stays in our store. independent of physical memory This means we can support an address space which is independent of physical memory (on a 32 bit machine, there are 2 32 addresses in virtual memory). Paging – divide physical memory into fixed size blocks. 3

Quick recap – Paging and Virtual Memory pages The virtual address space is divided into pages. page frames frames The corresponding units on physical memory are called page frames or frames. Memory is managed with the aid of an MMU. The mapping of pages to page frames can be too large to effectively answer our demands. Solution: use a two level page system. 4

Quick recap – TLB associative memory Translation Look aside Buffer (associative memory) is a small table residing in the MMU. Each entry contains information about one page. The TLB maps virtual pages to a physical address without going through the page table. Traditionally implemented in hardware (lookup of entries is done in a single step). When a miss occurs, an ordinary page table lookup is done (and the TLB is updated). 5

Quick recap – Inverted Page Table The IPT uses one entry per frame (physical memory), instead of per page (virtual memory). on every memory reference Virtual to physical translation may become significantly harder: when process n references virtual page p we now have to go over the entire IPT for an entry (n,p) – this must be done on every memory reference! Tradeoff: amount of memory required for the page table vs. time required to search for a page. Often used with a hash function to speed up search. 6

Question 1 Assume a 32 bit system, with 2-level page table (page size is 4K, |p 1 |=|p 2 |=10bits, |offset|=12bits). Program “A” on this system requires 12 MB of memory. The bottom 4MB of memory for program text, followed by 4MB for data and lastly, the top 4MB for stack. 1. How many page tables are actually required for this process. 2.Describe the lookup within the page tables of address 0x

Question 1 We use the following scheme: The 12 least significant digits in this address, allow access for 2 12 bytes – 4 Kb. These are pointed to by any of the 2 10 entries of p 2. In total, a second level page table can point to 2 22 bytes – 4 MB. Each such page table is pointed to by a first level table entry. In our case – we require 4 page tables: a single first level page table, which points to 3 second level page tables. page offset p1p1 p2p2 d

Question 1 page number page offset p1p1 p2p2 d Top-level page table bit virtual address, 4K pages, lookup of 0x (4,206,596 (dec) ) Binary: = 1 (dec) = 3 (dec) = 4 (dec) – 8 MB – Byte 9

Question 2 Consider a paged memory system with two-level page table. If a memory reference takes 20 nanoseconds (ns), how long does a paged memory reference take? Assume that the second-level page table is always in memory, and: a)There is no TLB, and the needed page is in main memory. b)There is a TLB, with access speed of 0.05 ns, the needed page is in main memory and i.The TLB does not contain information on this page. ii.The TLB contains information on this page. 10

Question 2 a)We will need to access the memory thrice: in the first and second accesses we will get the first and second level page table entry. This will point us to the physical address we will access next. Total time: 3x20 = 60ns. b)Remember we first access the TLB: i.Since this entry is not located in the TLB, after examining it, we will revert to the regular lookup scheme (as before). Total time: x20 = 60.05ns. ii.If the entry is in the TLB, after examining it we will know the location of the exact page frame and access it directly. Total time: = 20.05ns. Note that the use of virtual memory may significantly reduce memory performance. The TLB provides a mechanism to overcome this problem. 11

Question 3 Consider a computer with an address space of 32 bits, and a 2K page size. 1.What is the maximal size of the page table (single level), assuming each entry is 4 bytes? What is the maximal size of a program’s memory? Does it depends on the size of the pages? 2.Assume a two level page table, in which 8 bits are dedicated for the first level table. What is the maximal size of the 2 nd table? Can we run larger programs now? 12

Question 3 1.The virtual memory size is 2 32 bytes, and the size of each page is 2K (2 11 bytes). Total number of pages is therefore 2 32 /2 11 =2 21 pages. Since each entry is 4 bytes long, we require 4x2 21 = 2 23 bytes = 8 MB to hold this table. Maximal program size is 4 GB (size of virtual memory), regardless of the page size. 13

Question 3 2.Using 8 bits for the first level page table, leaves us with 2 13 bits for the second level page table. The size of the second table is 4x2 13 = 32Kb. The size of the virtual memory stays the same, and we can’t run bigger programs. 14

Question 4 1.What is the minimal size of a single level page table on a 32 bit machine, with 4KB pages? 2.What is the size of a 64 bit machine’s page table with 4KB pages? How many layers will we need if we want to ensure that each page table will require only a single address? 3.What is the size of the inverted page table, for a computer with 2GB RAM, in which each page is 16KB long and each entry is 8 bytes long? 15

Question 4 1.If the address space consists of 2 32 bytes, with 4KB pages, we have 2 32 /2 12 =2 20 entries (over 1 million). Using 4 bytes per entry, we get a 4MB page table. 2.With a 64 bit machine, we need 2 52 entries. Each entry being 8 bytes long results in a more than 30 PetaByes (Peta > Tera > Giga) page table. Limiting page table size to pages, means that we can only use 2 12 /2 3 =2 9 entries in each table, leading to 52/9≈6 layers. That means 6 memory accesses for each address translation. 16

Question 4 3. IPT has an entry per frame. That means that we must first divide the physical memory to frames, so we will know the amount of entries: 2GB = 2 31 bytes 2 31 /2 14 = 2 17 entries Each entry is 8 bytes long, so the total size is: 2 17 x2 3 = 2 20 bytes = 1MB 17