Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.

Slides:



Advertisements
Similar presentations
Module 10: Virtual Memory
Advertisements

Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Chapter 8 Virtual Memory
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
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.
Module 9: Virtual Memory
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Memory Management Design & Implementation Segmentation Chapter 4.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
Virtual Memory Chapter 8.
Virtual Memory Chapter 8.
03/26/2010CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying an earlier.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Lecture 11: Memory Management
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management 2010.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
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.
1 Lecture 9: Virtual Memory Operating System I Spring 2007.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Virtual Memory Chapter 8.
CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
Chapter 3 Memory Management: Virtual Memory
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Operating Systems Chapter 8
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.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 4 Memory Management Virtual Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Memory Management Operating Systems CS550. Memory Manager Memory manager - manages allocation and de-allocation of main memory Plays significant impact.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
1 Lecture 8: Virtual Memory Operating System Fall 2006.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Virtual Memory. 2 Last Week Memory Management Increase degree of multiprogramming –Entire process needs to fit into memory Dynamic Linking and Loading.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Virtual Memory Chapter 8.
CS703 - Advanced Operating Systems
ITEC 202 Operating Systems
Chapter 8 Virtual Memory
Virtual Memory Chapter 8.
Lecture 10: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual Memory
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.
5: Virtual Memory Background Demand Paging
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Main Memory Background Swapping Contiguous Allocation Paging
Chapter 6 Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 542: Operating Systems
Module 9: Virtual Memory
COMP755 Advanced Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Memory Management ◦ Operating Systems ◦ CS550

Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous allocation  Non-contiguous allocation removes this problem  Modern memory systems use more advanced allocation schemes -Paging -Segmentation

Paging o Process address space divided into pages which have a 1-to-1 correspondence with frames o Frames are fixed size blocks of physical memory o Page size is a power of two e.g. 1024bytes or 1K o No external fragmentation o Internal fragmentation occurs on the last page of a process o Remember, memory for a process includes program and data o Not stored contiguously

Logical addresses o Logical address of a process consists of a page number and a process o Physical address is determined by the frame number and the offset o Use the page table to keep track of which frame corresponds to which page o Could be an array or linked list o One table entry per page (per frame) o Most sig. bits - page number o Least sig. bits – offset o For real page table w/20 bit addressing, have 1024 pages with 1024bytes each first 10 bits - address next 10 – offset o page 2 o offset 478 bytes

Page number provides an index into the page table Offset provides value into memory | page # | offset | This figure will also be drawn in class. The OS must do the translation Logical addresses (Contd..)

Segmentation o Segments are variable length modules of a program corresponding to logical units (addresses) o Represent modular structure of program o Examples include: o Main method o Other methods o Data o All need to be loaded into memory o Prefer to load segments into contiguous blocks of memory

Differences: Paging and Segments  Segments not all of the same size  Segments could be large compared to size of page  Number of segments in a process is small  Operating system often keeps a segment table  It keeps track of all segments for a process including starting address and length  Need to use segment table to get to physical address via page table

Virtual Memory o Memory space of process divided into blocks of pages or segments o Don't need all blocks to execute a process though o Virtual address space of a process is the entire set of all addresses in a program o Keep absolute form of program on disk o Physical address space is much smaller o Virtual memory manager swaps out pages/segments of an executing process as needed o Operating system must provide a way to translate between virtual and physical addresses o Virtual address space is much larger than physical address space o Need efficient way to load blocks as program executes o Swap space or page file

Process locality o Often only reference subset of memory references while program executes reference locality o Process executes in steps and usually only some memory is needed during those steps o Sets of pages a process operates on are called a locality Segmentation o Often only a few segments are needed at once. o Segments may be of variable size o Only need to load a few segments into memory o When need another segment go to page file/swap space and get data (called a page fault) o Transfer replaced segment back to memory o No control from user on how to divide segments

 Check for valid page number  Check for valid physical address  OS must trigger an interrupt to access memory/disk if page is not in memory  OS must write data (pages) back to disk if there are modifications to physical memory within the program (must keep page file up to date) uses a bit to indicate this  Managing page table can be costly may need to only load part of it into memory  Important to consider page size (too big/too small) Address Translation

Paging with virtual memory o May allocate few pages to a process of large size o When process references page not in memory page fault occurs o Costs time to handle a page fault (OS overhead) Paging Policies o When to swap a page - fetch policy o Replacement policy - select page to replace if no empty frames o Placement policy - where to place page (which frame) in memory o Number of frames to allocate to a process

Fetch Policy Demand paging - page not loaded until referenced in memory by program Prepaging - load page before it is referenced by program With demand paging faults occur when need instruction need operand of an instruction With prepaging need to be careful about which pages to load esp. if not using them soon

Replacement Policy Carry out these steps when page fault occurs Process generating fault is suspended OS locates referenced page on HDD using page tables If no free frame select page to replace and transfer this page back to HDD Load referenced page into selected frame and update page/frame tables Resume interrupted process Need replacement policy Need to examine modified bit to determine if we need to store a page in memory

Frame Allocation Need to be careful about how many pages to allocate to a process Too few frames = lots of page faults Causes thrashing - worse than deadlock because processes don't make progress Use equal or proportional allocation (proportional to size) With replacement, use local and global allocation local - select only from own set of frames global - select from other process frames or empty ones

Page Faults & Performance Time to service page fault important (overhead) Time interval to service page fault interrupt Time to swap out (store) replaced page to HDD Time to swap in (load) referenced page from HDD Delay in queuing for HDD Delay in scheduling process with referenced page Disk I/O time is most significant page fault rate its number of Page faults per unit of execution time Unit of execution time defined as time without page faults + number of faults * fault service time

Paging Algorithm Implement replacement policy Static frame allocation policies Dynamic frame allocation policies Based on how frames allocated to a process Assume process has a reference stream of pages and ref stream represents process actions We have 3 static policies FIFO Optimal replacement LRU

In class we will look at a FIFO example with 3 page segment... This may exhibit poor performance even if number of frames increased Optimal algorithm needs entire page reference stream in advance Replace page in memory that will not be used for the longest period LRU replace page in memory that has not been used for the longest period [1, 2] Paging Algorithm (Contd..)