1 Virtual Memory Sample Questions Project 3 – Build Pthread Lib Extra Office Hour: Wed 4pm-5pm HILL 367 Recitation 6.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Advertisements

Chapter 4 Memory Management Basic memory management Swapping
Cache and Virtual Memory Replacement Algorithms
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Memory Management.
Page Replacement Algorithms
Basic Memory Management Monoprogramming Protection Swapping Overlaying OS space User space.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Lecture 8: Memory Hierarchy Cache Performance Kai Bu
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
1 Memory Management Managing memory hierarchies. 2 Memory Management Ideally programmers want memory that is –large –fast –non volatile –transparent Memory.
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
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 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Paging Algorithms Vivek Pai / Kai Li Princeton University.
Introduction to Systems Programming Lecture 7
Virtual Memory Chapter 8.
Chapter 3.2 : Virtual Memory
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
Memory Management 2 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Virtual Memory.
Memory Systems Architecture and Hierarchical Memory Systems
CS333 Intro to Operating Systems Jonathan Walpole.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Memory Management Page replacement algorithms, segmentation Tanenbaum, ch. 3 p Silberschatz, ch. 8, 9 p
Memory Management From Chapter 4, Modern Operating Systems, Andrew S. Tanenbaum.
Memory Management The part of O.S. that manages the memory hierarchy (i.e., main memory and disk) is called the memory manager Memory manager allocates.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
By Andrew Yee. Virtual Memory Memory Management What is Page Replacement?
Fundamentals of Programming Languages-II Subject Code: Teaching SchemeExamination Scheme Theory: 1 Hr./WeekOnline Examination: 50 Marks Practical:
“ Memory Management Function ” Presented By Lect. Rimple Bala GPC,Amritsar 1.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
Demand Paging Reference Reference on UNIX memory management
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
操作系统原理 OPERATING SYSTEM Chapter 3 Memory Management 内存管理.
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)
1 Lecture 8: Virtual Memory Operating System Fall 2006.
1 Memory Management Chapter Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement.
1 Memory Management Adapted From Modern Operating Systems, Andrew S. Tanenbaum.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
PAGE REPLACEMNT ALGORITHMS FUNDAMENTAL OF ALGORITHMS.
Memory Management Chapter 3
Logistics Homework 5 will be out this evening, due 3:09pm 4/14
Demand Paging Reference Reference on UNIX memory management
Instructor: Junfeng Yang
Chapter 9 Virtual Memory
Demand Paging Reference Reference on UNIX memory management
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Virtual Memory فصل هشتم.
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
CSC3050 – Computer Architecture
Computer Architecture
Lecture 9: Caching and Demand-Paged Virtual Memory
Virtual Memory.
Presentation transcript:

1 Virtual Memory Sample Questions Project 3 – Build Pthread Lib Extra Office Hour: Wed 4pm-5pm HILL 367 Recitation 6

2 Registers Cache Memory Virtual Memory Memory Hierarchy Answer: Pretend we had something bigger => Virtual Memory

3 Memory Access Cost

4 Virtual Memory Paging (1) The position and function of the MMU

5 Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table

6 Paging: Address Translation CPU pd p f fd f d page table memory virtual address physical address

7 Page Tables (1) Internal operation of MMU with 16 4 KB pages

8 Two-Level Page-Table Scheme

9 Translation Lookaside Buffers Translation on every memory access  must be fast What to do? Caching, of course … –Why does caching work? Temporal locality! –Same as normal memory cache – cache is smaller so can spend more $$ to make it faster Cache for page table entries is called the Translation Lookaside Buffer (TLB) –Typically fully associative –Relatively small number of entries (e.g., 64 or 128 entries) On every memory access, we look for the page  frame mapping in the TLB

10 Paging: Address Translation with TLB  TLB hit/ TLB miss CPU pd fd f d TLB memory virtual address physical address p/f f

11 Terms Page frames (Virtual) Pages Page fault Hit /Miss Page table TLB

12 Page Replacement Highly motivated to find a good replacement policy –That is, when evicting a page, how do we choose the best victim in order to minimize the page fault rate? Is there an optimal replacement algorithm? If yes, what is it? Let’s look at an example: –Suppose we have 3 memory frames and are running a program that has the following reference pattern 7, 0, 1, 2, 0, 3, 0, 4, 2, 3 Algorithms: Optimal, Not Recently Used(NRU), Second Chance, FIFO, LRU(Least Recently Used), Working Set & Clock, Nth Chance …

13 Optimal Page Replacement Suppose we know the access pattern in advance 7, 0, 1, 2, 0, 3, 0, 4, 2, 3 Optimal algorithm is to replace the page that will not be used for the longest period of time What’s the problem with this algorithm? Realistic policies try to predict future behavior on the basis of past behavior –Works because of locality

14 Not Recently Used Page Replacement Algorithm Each page has Reference bit, Modified bit –bits are set when page is referenced, modified Pages are classified 1. not referenced, not modified 2. not referenced, modified 3. referenced, not modified 4. referenced, modified NRU removes page at random –from lowest numbered non empty class

15 FIFO Page Replacement Algorithm Maintain a linked list of all pages –in order they came into memory Page at beginning of list replaced (remove the last cell) Disadvantage –Last cells may be often used

16 Least Recently Used (LRU) Assume pages used recently will used again soon –throw out page that has been unused for longest time Must keep a linked list of pages –most recently used at front, least at rear –update this list every memory reference !! Alternatively keep counter in each page table entry –choose page with lowest value counter –periodically zero the counter

17 Segmentation (1) One-dimensional address space with growing tables One table may bump into another

18 Segmentation (2) Allows each table to grow or shrink, independently

19 Segmentation (3) Comparison of paging and segmentation

20 Implementation of Pure Segmentation (a)-(d) Development of checkerboarding (e) Removal of the checkerboarding by compaction

21 Segmentation with Paging: MULTICS (1) Descriptor segment points to page tables Segment descriptor – numbers are field lengths

22 Segmentation with Paging: MULTICS (2) A 34-bit MULTICS virtual address

23 Example Question1 4 page frames, page requests= Page Fault Rate??? For FIFO, LRU, (OPT) FIFO MMMMMH H HMH LRU MMMMMH H HMM

Example Question 2 Assume a process is divided into 4 equal-sized segments, and that the system builds a 16-entry page descriptor for each segment. Thus, the system has a combination of segmentation & paging. Assume also that the page size is 4KB. a)What is the maximum size of each segment? b)Assume that an element in physical location 0x21ABC (in hex) is accessed by a thread of this process. What segment, page & offset is the thread trying to access? 24 ANSWER: a)16 * 4KB b)4K = 2^12, therefore, ABC is for offset. 16=2^4,  page 1. and “2” is for segment

Example Question 3 A computer has 32-bit virtual addresses & 4-KB pages. The program and data together fit in the lowest page (0-4095). The stack fits in the highest page. How many entries are needed in the page table if one-level paging is used? How many for 2-level page, with 10 bits in each part? 25 ANSWER: Twenty bits are used for the virtual page numbers, leaving 12 over for the offset. This yields a 4-KB page. Twenty bits for the virtual page implies 2^20 pages.

Example Question 4 A computer whose processes have 1024 pages in their address spaces keeps its page tables in memory. The overhead required for reading a word from the page table is 5 ns. To reduce this overhead, the computer has a TLB, which hold 32 (virtual page->physical page frame) pairs, and can do a look up in 1 ns. What hit rate is needed to reduce the mean overhead to 2 ns? 26 ANSWER: The effective instruction time is 1h + 5(1 − h), where h is the hit rate. If we equate this formula with 2 and solve for h, we find that h must be at least 0.75.

Project 3 Nov 7, :00 pm Implement basic functions of Pthread Lib. Use makecontext(), getcontext(), setcontext(), and swapcontext(). Useful Link: – 5399/functions/makecontext.htmlhttp:// 5399/functions/makecontext.html 27