“ Memory Management Function ” Presented By Lect. Rimple Bala GPC,Amritsar 1.

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
Memory Management.
Chapter 4 Memory Management Page Replacement 补充:什么叫页面抖动?
Part IV: Memory Management
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.
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.
CS 311 – Lecture 21 Outline Memory management in UNIX
1 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
CS 104 Introduction to Computer Science and Graphics Problems
Chapter 3.2 : Virtual Memory
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
CS 333 Introduction to Operating Systems Class 9 - Memory Management
1 Virtual Memory Sample Questions Project 3 – Build Pthread Lib Extra Office Hour: Wed 4pm-5pm HILL 367 Recitation 6.
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.
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.
CS 333 Introduction to Operating Systems Class 9 - Memory Management Jonathan Walpole Computer Science Portland State University.
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.
Operating Systems Chapter 8
Memory Management. Process must be loaded into memory before being executed. Memory needs to be allocated to ensure a reasonable supply of ready processes.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
CS333 Intro to Operating Systems Jonathan Walpole.
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 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.
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.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Chapter 4 Memory Management Virtual Memory.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
Memory Management. Introduction To improve both the utilization of the CPU and the speed of its response to users, the computer must keep several processes.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
1 Memory Management Review of Designs and Issues Basic memory management Swapping Virtual memory Page replacement algorithms Design issues for paging systems.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
操作系统原理 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.
1 Memory Management Adapted From Modern Operating Systems, Andrew S. Tanenbaum.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Main Memory CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Memory Management Chapter 3
UNIT–IV: Memory Management
Main Memory Management
Chapter 8: Main Memory.
Chapter 4 Memory Management 4.1 Basic memory management 4.2 Swapping
Chapter 9: Virtual-Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Management-I 1.
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

“ Memory Management Function ” Presented By Lect. Rimple Bala GPC,Amritsar 1

Contents 2  Basic memory management  Swapping  Virtual memory  Paging Page replacement algorithms Modeling page replacement algorithms Design issues for paging systems Implementation issues  Segmentation

Memory Management  Memory – a linear array of bytes Holds O.S. and programs (processes) Each cell (byte) is named by a unique memory address  Recall, processes are defined by an address space, consisting of text, data, and stack regions  Process execution CPU fetches instructions from the text region according to the value of the program counter (PC) Each instruction may request additional operands from the data or stack region 3

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 4

Multiprogramming with Fixed Partitions  Fixed memory partitions separate input queues for each partition single input queue 5

Modeling Multiprogramming CPU utilization as a function of number of processes in memory 6 Degree of multiprogramming

Names and Binding Symbolic names  Logical names  Physical names ○ Symbolic Names: known in a context or path file names, program names, printer/device names, user names ○ Logical Names: used to label a specific entity job number, major/minor device numbers, process id (pid), uid. ○ Physical Names: address of entity inode address on disk or memory entry point or variable address PCB address

Address Binding  Address binding fixing a physical address to the logical address of a process’ address space  Compile time binding if program location is fixed and known ahead of time  Load time binding if program location in memory is unknown until run-time AND location is fixed  Execution time binding if processes can be moved in memory during execution Requires hardware support

P: : push... jmp 175 : foo: Library Routines P: : push... jmp 1175 : foo: Library Routines P: : push... jmp 1175 : foo: Library Routines P: : push... jmp 175 : foo: Library Routines 1000 Base register Execution Time Address Binding Load Time Address Binding Compile Time Address Binding

Dynamic relocation with a base register  Memory Management Unit (MMU) - dynamically converts logical addresses into physical address  MMU contains base address register for running process process i Operating system Max addr 0 Max Mem 0 Physical memory address Relocation register for process i MMU Program generated address

Protection using base & limit registers  Memory protection Base register gives starting address for process Limit register limits the offset accessible from the relocation register base + Physical address memory register < limit register yes no addressing error logical address

Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate physical address space is central to proper memory management. ○ Logical Address: or virtual address - generated by CPU ○ Physical Address: address seen by memory unit. Logical and physical addresses are the same in compile time and load-time binding schemes Logical and physical addresses differ in execution-time address-binding scheme. 11/26/201512Edusat lect. Rimple GPC,Amritsar

Features of Memory Management  Relocation 1. Static 2. Dynamic  Protection  Sharing  Logical organization  Physical organization  Memory Compaction 13

Various Methods used by OS  Swapping  Virtual Memory  Paging  Segmentation 14

Swapping Memory allocation changes as processes come into memory leave memory Shaded regions are unused memory 15

Swapping  Allocating space for growing data segment  Allocating space for growing stack & data segment 16

Memory Management with Bit Maps  Part of memory with 5 processes, 3 holes tick marks show allocation units shaded regions are free  Corresponding bit map  Same information as a list 17

Memory Management with Linked Lists Four neighbor combinations for the terminating process X 18

Managing memory with linked lists Searching the list for space for a new process First Fit Next Fit ○ Start from current location in the list Best Fit ○ Find the smallest hole that will work ○ Tends to create lots of really small holes Worst Fit ○ Find the largest hole ○ Remainder will be big Quick Fit ○ Keep separate lists for common sizes

Virtual Memory  Virtual Memory ○ Separation of user logical memory from physical memory. ○ Only PART of the program needs to be in memory for execution. ○ Logical address space can be much larger than physical address space. ○ Need to allow pages to be swapped in and out.  Virtual Memory can be implemented via Paging Segmentation

Virtual Memory The position and function of the MMU 21

Paging The relation between virtual addresses and physical memory addresses given by page table 22

Page Tables Internal operation of MMU with 16 4 KB pages 23

Page Tables  32 bit address with 2 page table fields  Two-level page tables 24 Top-level page table

Page Tables Typical page table entry 25

TLBs – Translation Look aside Buffers A TLB to speed up paging 26

Inverted Page Tables Comparison of a traditional page table with an inverted page table 27

Page Replacement Algorithms  Page fault forces choice which page must be removed make room for incoming page  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 28

Page Replacement Algorithms  Optimal Page Replacement  Not Recently Used Page Replacement Algorithms.  FIFO Page Replacement Algorithms  Second Chance Algorithms  Clock Page Replacement Algorithms  Least Recently used 29

Optimal Page Replacement Algorithm  Replace page needed at the farthest point in future Optimal but unrealizable  Estimate by … logging page use on previous runs of process although this is impractical 30

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 31

FIFO Page Replacement Algorithm  Maintain a linked list of all pages in order they came into memory  Page at beginning of list replaced  Disadvantage page in memory the longest may be often used 32

Second Chance Page Replacement Algorithm  Operation of a second chance pages sorted in FIFO order Page list if fault occurs at time 20, A has R bit set 33

The Clock Page Replacement Algorithm 34

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 35

Review of Page Replacement Algorithms 36

Modeling Page Replacement Algorithms Belady's Anomaly  FIFO with 3 page frames  FIFO with 4 page frames  P's show which page references show page faults 37

Stack Algorithms State of memory array, M, after each item in reference string is processed

Page Size Small page size  Advantages less internal fragmentation better fit for various data structures, code sections less unused program in memory  Disadvantages programs need many pages, larger page tables 39

Page Size  Overhead due to page table and internal fragmentation  Where s = average process size in bytes p = page size in bytes e = page entry 40 page table space internal fragmentation Optimized when

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

Implementation Issues Four times when OS involved with paging 1. Process creation  determine program size  create page table 2. Process execution  MMU reset for new process  TLB flushed 3. Page fault time  determine virtual address causing fault  swap target page out, needed page in 4. Process termination time  release page table, pages 42

Backing Store (a) Paging to static swap area (b) Backing up pages dynamically 43

Separation of Policy and Mechanism Page fault handling with an external pager 44

Segmentation  One-dimensional address space with growing tables  One table may bump into another 45

Segmentation Allows each table to grow or shrink, independently 46

Implementation of Pure Segmentation 47

Segmentation with Paging: MULTICS A 34-bit MULTICS virtual address 48

Segmentation with Paging: MULTICS Conversion of a 2-part MULTICS address into a main memory address 49

Segmentation with Paging: MULTICS

Disadvantages of Segmentation 1. Segmentation mapping requires two memory references per logical address which slows down the computer system. Caching is the method used to solve this problem 2. Where there is more number of segments, segment table size will grow. so it cannot be accommodated in any of the registers and has to be kept in memory 3.Segmentation is prone to external fragmentation. This may occur when all the blocks in memory are too small to accommodate a segment 51

Advantages of Segmentation  Protection bits are associated with segments, which check that attempt to write a read only segment should fail.  As with paging sharing of code or data is possible even with the segmentation technique. Here entries in two different segment tables can be made to point to a common physical location. 52

Comparison of paging and segmentation 53

Summary  The memory management allows us how to manage the memory.  The virtual memory is the memory which does not existence.  The paging process which allows us to change the pages from memory to the secondary storage devices such processes are known as swap in and swap out.  The segmentation allows us to make the division of the memory into the various segments  The fragmentation occurs due to internally or externally wasteage of memory.  The page replacement is the concept of changing the page from the various frames in the memory whenever required.the page replacement is needed due to the page fault. 54

55