1 Memory Management Adapted From Modern Operating Systems, Andrew S. Tanenbaum.

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
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.
Basic Memory Management Monoprogramming Protection Swapping Overlaying OS space User space.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Memory management Lecture 7 ~ Winter, 2007 ~.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 13: Main Memory (Chapter 8)
Memory Management Paging &Segmentation CS311, CS350 & CS550.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Virtual Memory Introduction to Operating Systems: Module 9.
1 Memory Management Managing memory hierarchies. 2 Memory Management Ideally programmers want memory that is –large –fast –non volatile –transparent Memory.
Memory Management Design & Implementation Segmentation Chapter 4.
1 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Paging Design.
Memory Management 2010.
Virtual Memory Chapter 8.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 3.2 : Virtual Memory
1 Pertemuan 11 Manajemen Memori Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5 OFFCLASS02.
Chapter 3 Memory Management
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Segmentation Memory-management scheme that supports user view of memory. A program.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
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.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
Operating Systems Chapter 8
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
1 Memory Management Chapter Basic memory management 4.2 Swapping (εναλλαγή) 4.3 Virtual memory (εικονική/ιδεατή μνήμη) 4.4 Page replacement algorithms.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
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.
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.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Chapter 4 Memory Management Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
“ Memory Management Function ” Presented By Lect. Rimple Bala GPC,Amritsar 1.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
1 Memory Management Review of Designs and Issues Basic memory management Swapping Virtual memory Page replacement algorithms Design issues for paging systems.
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 内存管理.
1 Memory Management Chapter Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Virtual Memory What if program is bigger than available memory?
Memory Management Chapter 3
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 8: Main Memory.
Chapter 8: Main Memory.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Page Replacement.
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
COMP755 Advanced Operating Systems
Virtual Memory.
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

1 Memory Management Adapted From Modern Operating Systems, Andrew S. Tanenbaum

2 Memory Management Ideally programmers want memory that is –large –fast –non volatile Memory hierarchy –small amount of fast, expensive memory – cache –some medium-speed, medium price main memory –gigabytes of slow, cheap disk storage Memory manager handles the memory hierarchy

3 Basic Memory Management Monoprogramming without Swapping or Paging Three simple ways of organizing memory (in an operating system with one user process)

4 Multiprogramming with Fixed Partitions Fixed memory partitions –separate input queues for each partition –single input queue

5 Relocation and Protection Cannot be sure where program will be loaded in memory –address locations of variables, code routines cannot be absolute (see next slide) –must keep a program out of other processes’ partitions Use base and limit values –address locations added to base value to map to physical addr –address locations larger than limit value is an error

Seeing the problem extern int x;// placement determined by loader void Fcn (void){int y; x=x+1;} Compiles to: but where is x at runtime? 6 Compiled address (in 32-bit words) instruction [0]define storage for x – outside program 0[function initialization (10 words)] 10load address of x 11load x 12add 1 to x 13store result

7 Swapping (1) Memory allocation changes as –processes come into memory –leave memory Shaded regions are unused memory

8 Swapping (2) a.Allocating space for growing data segment b.Allocating space for growing stack & data segment

9 Page Replacement Algorithms (1) Page fault forces choice –which page must be removed (the “victim”) Modified page must first be saved –unmodified just overwritten Better not to choose an often used page –will probably need to be brought back in soon

10 Page Replacement Algorithms (2) Optimal Page Replacement –Replace page needed at the farthest point in future –Optimal but unrealizable (Why?) FIFO Not Recently Used (NRU) Clock Second Chance Least Recently Used (LRU) rarely implemented - why? Not Frequently Used (NFU) Aging Working Set WSClock

11 Design Issues for Paging Systems Local versus Global Allocation Policies Original configuration Local page replacement Global page replacement

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

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

14 Page Tables (1) Internal operation of MMU with 16 4 KB pages = = = bits for real address 16-bit vaddr Remaining 8 pages not mapped

15 Page Tables (2) 32 bit address with 2 page table fields 8 bytes/entry OK for 32-bit machine 64-bit machine needs 2 52 entries >30GB Top-level page table Second-level page tables

16 Page Tables (3) Typical page table entry

17 TLBs – Translation Lookaside Buffers A TLB to speed up paging

18 3 table schemes Inverted table 1 entry/page in memory PID+V. Page# See cs

Problem with IPT’s Virtual-real translation harder Cannot use virtpg# as index –must search entire table –On EVERY reference 19

20 Cleaning Policy Need for a background process, paging daemon –periodically inspects state of memory When too few page frames are free –selects pages to evict using a replacement algorithm

21 Load Control Despite good designs, system may still thrash when –some processes need more memory –but no processes need less Solution : Reduce number of processes competing for memory –swap one or more to disk, divide up pages they held –reconsider degree of multiprogramming

22 Page Size Small page size Advantages –less internal fragmentation –better fit for various data structures, code sections Disadvantages –program needs more pages  has larger page table

23 Separate Instruction and Data Spaces One address space Separate I and D spaces

24 Shared Pages Two processes sharing same program sharing its page table

25 References Chapters 8 and 9 :OS Concepts, Silberschatz, Galvin, Gagne Chapter 4: Modern Operating Systems, Andrew S. Tanenbaum X86 architecture – Memory segment – Memory model – IA-32 Intel Architecture Software Developer’s Manual, Volume 1: Basic Architecture –