LINUX 15 : Memory Management

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
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.
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 36 Virtual Memory Read.
Virtual Memory Management G. Anuradha Ref:- Galvin.
Case Study: Virtual Memory in UNIX Reference – Maurice J.Bach, The Design of the UNIX Operating System Terminology - Physical Memory (Main Memory) Secondary.
Virtual Memory Operating System Concepts chapter 9 CS 355
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory OSC: Chapter 9. Demand Paging Copy-on-Write Page Replacement.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Memory Management Policies: UNIX
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
Introduction to Kernel
Virtual Memory Chapter 8.
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.
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
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.
Virtual Memory CS 147 October 30, 2007 Chris Stewart.
Computer Organization and Architecture
Virtual Memory Deung young, Moon ELEC 5200/6200 Computer Architecture and Design Lectured by Dr. V. Agrawal Lectured by Dr. V.
1 Memory Management in Representative Operating Systems.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
Operating Systems Chapter 8
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
Chapter 4 Storage Management (Memory Management).
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Computer Studies (AL) Memory Management Virtual Memory I.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Virtual Memory 1 Chapter 13. Virtual Memory Introduction Demand Paging Hardware Requirements 4.3 BSD Virtual Memory 4.3 BSD Memory Management Operations.
Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory.
Unit - III Memory management and Virtual memory. Contents : Swapping Demand paging Hybrid System with swapping and demand paging Memory management requirements.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Computer Systems Week 14: Memory Management Amanda Oddie.
Paging (continued) & Caching CS-3013 A-term Paging (continued) & Caching CS-3013 Operating Systems A-term 2008 (Slides include materials from Modern.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Virtual Memory.
Memory Management Chapter 7.
Introduction to Kernel
Paging.
Chapter 2: The Linux System Part 4
Memory Management.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Virtual Memory CSSE 332 Operating Systems
Chapter 2 Memory and process management
File-System Implementation
Chapter 9: Virtual Memory – Part I
Chapter 9: Virtual Memory
Structure of Processes
Virtual Memory Chapter 8.
Main Memory Management
O.S Lecture 13 Virtual Memory.
Chapter 9: Virtual-Memory Management
ECE 445 – Computer Organization
Module IV Memory Organization.
What Happens if There is no Free Frame?
Main Memory Background Swapping Contiguous Allocation Paging
Overview: File system implementation (cont)
Lecture 3: Main Memory.
Virtual Memory Virtual memory is a technique which gives an application program the impression that it has contiguous working memory, while in fact it.
Memory Management and I/O Subsystem
CSE 542: Operating Systems
Presentation transcript:

LINUX 15 : Memory Management

Memory Primary memory is a precious resource that frequently cannot contain all active processes in the system The memory management system decides which processes should reside (at least partially) in main memory It monitors the amount of available primary memory and may periodically write processes to a secondary device called the swap device to provide more space in primary memory At a later time, the kernel reads the data from swap device back to main memory

Memory management subsystem Providing ways to allocate portions of memory to programs at their requests, and freeing it for reuse when no longer needed

Memory management subsystem Large address space Protection Memory mapping Fair physical memory allocation Shared virtual memory

Virtual Memory gives an application program the impression that it has contiguous working memory (an address space), while in fact it may be physically fragmented and may even overflow on to disk storage. Systems that use this technique make programming of large applications easier and use real physical memory (e.g. RAM) more efficiently than those without virtual memory

UNIX memory management Swapping Demand Paging

Swapping The swap device is a block device in a configurable section of a disk Kernel allocates contiguous space on the swap device without fragmentation It maintains free space of the swap device in an in-core table, called map The kernel treats each unit of the swap map as group of disk blocks As kernel allocates and frees resources, it updates the map accordingly

Swapping process out Memory  Swap device Kernel swap out when it needs memory When fork() called for allocate child process When called for increase the size of process When process become larger by growth of its stack Previously swapped out process want to swap in but not enough memory

Swapping process out The kernel must gather the page addresses of data at primary memory to be swapped out Kernel copies the physical memory assigned to a process to the allocated space on the swap device The mapping between physical memory and swap device is kept in page table entry

Swapping Process Out Mapping process onto the swap device Text Data : 128k 401k 66k 595k 65k 573k 1k 432k 0 278k Virtual Addresses Swap device 684 690 Text Data Stack Physical Addresses Mapping process onto the swap device

Swapping Process In Swapping a process into memory Text Data Stack Virtual Addresses Physical Addresses Swap device 684 Text 0 278k 1k 432k : Data 65k 573k 66k 595k 690 : Stack 128k 401k : Swapping a process into memory

Demand Paging Not all page of process resides in memory Locality When a process accesses a page that is not part of its working set, it incurs a page fault. The kernel suspends the execution of the process until it reads the page into memory and makes it accessible to the process

Page Table Entry and Disk Block Descriptor Region Page Table Page Table Entry Disk Block Descriptor Page Table Entry Page address age Cp/wrt mod ref val prot Disk Block Descriptor Type Block num Swap device

Page Table Entry Contains the physical address of page and the following bits: Valid: whether the page content legal Reference: whether the page is referenced recently Modify: whether the page content is modified copy on write: kernel must create a new copy when a process modifies its content (required for fork) Age: Age of the page Protection: Read/ write permission

Disk Block Descriptor Swap Device number as there may be several swap devices Block number that contains page Type Block num Swap device