Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Virtual Memory Background Demand Paging Performance of Demand Paging
Segmentation and Paging Considerations
Memory Management Design & Implementation Segmentation Chapter 4.
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.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management 2010.
Chapter 3.2 : Virtual Memory
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
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.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Computer Organization Cs 147 Prof. Lee Azita Keshmiri.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Memory Management CSE451 Andrew Whitaker. Big Picture Up till now, we’ve focused on how multiple programs share the CPU Now: how do multiple programs.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Tutorial 6 Memory Management
CS333 Intro to Operating Systems Jonathan Walpole.
Tutorial 7 Memory Management presented by: Antonio Maiorano Paul Di Marco.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
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.
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.
Chapter 4 Storage Management (Memory Management).
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Page 110/20/2015 CSE 30341: Operating Systems Principles So far…  Page  Fixed size pages solve page allocation problem (and external fragmentation) 
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
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.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
VIRTUAL MEMORY By Thi Nguyen. Motivation  In early time, the main memory was not large enough to store and execute complex program as higher level languages.
1 Address Translation Memory Allocation –Linked lists –Bit maps Options for managing memory –Base and Bound –Segmentation –Paging Paged page tables Inverted.
CE Operating Systems Lecture 14 Memory management.
Silberschatz, Galvin and Gagne Operating System Concepts Chapter 9: Virtual Memory.
Chapter 4 Memory Management Virtual Memory.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
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.
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.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
1 Memory Management n In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
VIRTUAL MEMORY.
Memory Management.
Virtual Memory CSSE 332 Operating Systems
Paging COMP 755.
COMBINED PAGING AND SEGMENTATION
Virtual Memory Chapter 8.
Lecture 28: Virtual Memory-Address Translation
Operating System Concepts
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.
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 32 Syed Mansoor Sarwar
Lecture 3: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Lecture 7: Flexible Address Translation
Memory Management CSE451 Andrew Whitaker.
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles

What is Swap Space? The virtual address space of programs is often bigger than the physical address space of the computers they will run on For example, the virtual address space of a program running on a 32-bit machine will probably be 2 32 (Actually 2 31 since half is set aside for the kernel) Virtual memory systems support processes that are bigger than main memory by using disk space as backup storage. Swap space is a file, disk partition, or separate disk used originally to store suspended processes and today, in virtual memory systems, to store all or part of the virtual address space of currently executing processes.

Swap Space Use Executable files contain executable code and initialized data. Stack, heap, other dynamic elements aren’t included. Some systems store the entire process image, including executable code, in swap space; others page code in and out from the executable files and use swap space for stack, heap, etc. Some systems initialize swap space for a process when the process is created, others allocate space only when pages are evicted from memory. The amount of swap space needed by a system depends on a number of elements, including size of physical memory, virtual address space, etc.

Swap Space & the File System Two approaches: Swap space as a large file in the file system Swap space as a separate partition Swap space that’s part of the normal file system is easy to implement (just use existing file system functions) but the overhead of going through the directory system and disk allocation structures to swap pages in and out is a drag on system efficiency. If swap space is created as a separate partition, no file system is used. Instead, a special swap manager handles space allocation and page accesses

Swap Space Management Swap-space management focuses on speed rather than efficiency of disk usage. Swap space is accessed more frequently than the file system. Internal fragmentation may be created, but swap space objects have a short life span (just while program is running), whereas files may exist for years. Consequently the space will be reclaimed in a few fractions of a second. Some versions of Linux support either separate swap areas or swap files. A swap file can provide adequate speed if space is allocated to processes as a contiguous set of locations Using a separate disk for swapping improves performance by supporting concurrent access as well as by having more efficient allocation strategies.

Virtual Memory Review Organization of virtual address space Page table size/structure/access Address translation (virtual/logical to physical)

Virtual Memory Review Organization of program virtual address spaces (how executable binary files are organized): Code, usually located at some fixed (virtual) address, often 0. Data segment: contains non-stack, non-heap variables When a process is created from the program the stack is allocated at the high end of virtual memory; it can grow towards lower addresses Heap space is usually created at the same time and is at lower address space than the stack. They grow toward each other. Thus information is not stored consecutively; there are blocks of virtual memory that are empty

Page Table Issues Consider a simple, one-level page table. Size of page table is based on the maximum logical size of a process: one entry for each possible virtual page Not on the physical size of memory Not on the number of pages in the program (which is not known in advance anyway, since stack size and heap size vary from one execution to another) The logical page # selects the appropriate page table entry Typical contents of each entry: valid (or present) bit tells if the page is in memory Dirty bit tells if page has been modified Reference bit tells if page has been referenced (may be unset & reset) Protection bits (read only, etc)

Address Translation Page size (and frame size) is defined by the hardware Always a power of 2 Simplifies address translation by making it easy to divide the address into a page number and a page offset Formulas: given that the size of the logical address space is 2 m and the page size is 2 n then Page number ( p ) = the ( m - n ) high-order bits of the address Page offset ( d ) = the n low-order bits of the address Recall that address translation is done entirely by the hardware, using information in the page table, as long as the page is in memory Logical address p#d becomes physical address f#d (f=frame,p=page) Only if there is a page fault does the OS become involved.

Example Suppose parameters of the logical address space are m = 5 and n = 2; so p = m – n = 3 → 8 pages (2 p ) d = n → 4, indicating 4 addresses/page Suppose parameters of the physical address space are m = 4 and n = 2 p = 2 → 4 pages (2 p ) d = n → 4 addresses/page The page table must have 8 entries, even though there are only 4 pages of physical memory. Otherwise, you could not handle programs that are larger than memory. For example, suppose a process generated an address on logical page 5, such as 21

Index Valid bit Frame # FrameContent 0 Page 5 1 Page Page 2 Physical Memory Page Table (Red areas are not part of either page table or physical memory) If there weren’t 8 entries in the page table an address such as 21 ( ) could not be translated. But we can divide the address into two parts: 101|01 to get p = 101 2, and d = 01 2 or p = 5, d = 2.

Example