Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Advertisements

Module 10: Virtual Memory
Chapter 10: Virtual Memory
The Linux Kernel: Memory Management
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 13: Main Memory (Chapter 8)
Memory Management All data in memory before and after processing
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Module 9: Virtual Memory
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 9: Virtual Memory Background Demand Paging.
Chapter 10 Operating Systems.
CS 311 – Lecture 21 Outline Memory management in UNIX
Mobile Handset Memory Management
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.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.
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
Memory Management Policies: UNIX
Memory Management.
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.
Chapter 10: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 10: Virtual Memory.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Computer Organization and Architecture
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Chapter 10 Operating Systems.
Chapter 10 Operating Systems Nell Dale • John Lewis.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 8: Memory-Management Strategies Objectives To provide a detailed description.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
Silberschatz, Galvin and Gagne Operating System Concepts Chapter 9: Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
10-1 Software Categories Application software Software written to address specific needs—to solve problems in the real world Word processing programs,
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.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 9: Virtual-Memory Management 9.1 Background.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 2.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 5.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual-Memory Management.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Chapter 2: The Linux System Part 4
Virtual Memory CSSE 332 Operating Systems
Chapter 9: Virtual Memory – Part I
Chapter 9: Virtual Memory
Chapter 18: The Linux System
10CS53 Operating Systems Unit VIII Engineered for Tomorrow
10CS53 Operating Systems Unit VIII Engineered for Tomorrow
Main Memory Background Swapping Contiguous Allocation Paging
Mid-Term Review Good Results Always Answer Questions
Presentation transcript:

Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4

15.2 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Chapter 2: The Linux System Linux History Design Principles Kernel Modules Process Management Scheduling Memory Management File Systems Input and Output Interprocess Communication Network Structure Security

Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Memory Management

15.4 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Memory Management Linux’s physical memory-management system has two components: 1. Deals with allocating and freeing pages, groups of pages, and small blocks of memory. 2. Handling virtual memory, memory mapped into the address space of running processes.

15.5 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Memory Management Memory is a continuous set of bits referenced by specific addresses

15.6 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Partition Memory Management Partitions Main memory is divided into a particular number of partitions Programs are loaded into available partitions 10-6

15.7 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Paged Memory Management Paged memory technique: Processes are divided into fixed-size pages and stored in memory frames Frame: A piece of main memory that holds a process page Page: A piece of a process that is stored into a memory frame Page-map table (PMT): A table used by the operating system to keep track of page/frame relationships

15.8 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Paged Memory Management To produce a physical address, you first look up the page in the PMT to find the frame number in which it is stored Then multiply the frame number by the frame size and add the offset to get the physical address

15.9 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Paged Memory Management Demand paging An important extension of paged memory management Not all parts of a program actually have to be in memory at the same time In demand paging, the pages are brought into memory on demand Page swap The act of bringing in a page from secondary memory, which often causes another page to be written back to secondary memory 10-9

15.10 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Page Frame Management Page frames are 4KB in Linux. The kernel must keep track of the current status of each frame. Are page frames allocated or free? If allocated, do they contain process or kernel pages? Linux maintains an array of page frame descriptors (one for each frame) of type struct page.

15.11 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Page Frame Descriptors Each descriptor has several fields, including: count - equals 0 if frame is free, >0 otherwise. flags - an array of 32 bits for frame status.  Example flag values: – PG_locked - page cannot be swapped out. – PG_reserved - page frame reserved for kernel code or unusable.

15.12 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Managing Physical Memory The page allocator allocates and frees all physical pages; it can allocate ranges of physically-contiguous pages on request. The allocator uses a buddy-heap algorithm to keep track of available physical pages Each allocatable memory region is paired with an adjacent partner Whenever two allocated partner regions are both freed up they are combined to form a larger region If a small memory request cannot be satisfied by allocating an existing small free region, then a larger free region will be subdivided into two partners to satisfy the request. Memory allocations in the Linux kernel occur either statically (drivers reserve a contiguous area of memory during system boot time) or dynamically (via the page allocator).

15.13 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Splitting of Memory in a Buddy Heap

15.14 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Paged Memory Management The demand paging approach gives rise to the idea of virtual memory, the illusion that there are no restrictions on the size of a program. Too much page swapping, however, is called thrashing and can seriously degrade system performance

15.15 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Virtual Memory The VM system maintains the address space visible to each process: It creates pages of virtual memory on demand, and manages the loading of those pages from disk or their swapping back out to disk as required.

15.16 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Virtual Memory (Cont.) The kernel creates a new virtual address space 1.When a process runs a new program with the exec system call 2. Upon creation of a new process by the fork system call

15.17 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Virtual Memory (Cont.) On executing a new program, the process is given a new, completely empty virtual-address space; the program-loading routines populate the address space with virtual-memory regions. Creating a new process with fork involves creating a complete copy of the existing process’s virtual address space. The kernel copies the parent process’s VMA descriptors, then creates a new set of page tables for the child. The parent’s page tables are copied directly into the child’s, with the reference count of each page covered being incremented. After the fork, the parent and child share the same physical pages of memory in their address spaces.

15.18 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Virtual Memory (Cont.) The VM paging system relocates pages of memory from physical memory out to disk when the memory is needed for something else. The VM paging system can be divided into two sections: The pageout-policy algorithm decides which pages to write out to disk, and when The paging mechanism actually carries out the transfer, and pages data back into physical memory as needed

15.19 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Virtual Memory (Cont) This kernel virtual-memory area contains two regions: A static area that contains page table references to every available physical page of memory in the system, so that there is a simple translation from physical to virtual addresses when running kernel code. The reminder of the reserved section is not reserved for any specific purpose; its page- table entries can be modified to point to any other areas of memory.