1 Memory Management in Representative Operating Systems.

Slides:



Advertisements
Similar presentations
Chapter 9: Virtual Memory
Advertisements

Virtual Memory II Chapter 8.
Memory Management in Linux (Chap. 8 in Understanding the Linux Kernel)
Kernel memory allocation
Advanced Operating Systems - Spring 2009 Lecture 17 – March 23, 2009 Dan C. Marinescu Office: HEC 439 B. Office hours:
Chapter 11: File System Implementation
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Virtual Memory Chapter 8.
Memory Management (II)
Linux Vs. Windows NT Memory Management Hitesh Kumar
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
Lecture 11: Memory Management
Memory Management 2010.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
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.
Chapter 3.2 : Virtual Memory
1 File Management in Representative Operating Systems.
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.
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.
Computer Organization and Architecture
Virtual Memory Program addresses only logical addresses, Hardware maps to physical addresses Possible to load only part of a process into memory –Possible.
File System Implementation
1 I/O Management in Representative Operating Systems.
CSCI2413 Lecture 6 Operating Systems Memory Management 2 phones off (please)
Chapter 8 Virtual Memory Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice, FL ©2008,
Chapter 8 Virtual Memory
Computer Organization and Architecture Operating System Support Chapter 8.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
Chapter 8 Virtual Memory Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice.
Operating Systems Chapter 8
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.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
1 Virtual Memory (b). 2 Basic Page Replacement 1. Find the location of the desired page on disk. 2. Find a free frame: - If there is a free frame, use.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
Chapter 8 Virtual Memory Operating Systems: Internals and Design Principles Seventh Edition William Stallings.
Paging Example What is the data corresponding to the logical address below:
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.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Virtual Memory Chapter 8. 2 Virtual memory concept Simple paging/ segmentation  pages or segments are loaded into frames that may not necessarily be.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 11 File-System Implementation Slide 1 Chapter 11: File-System Implementation.
Introduction to Virtual Memory and Memory Management
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
LINUX 15 : Memory Management
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
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 ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Chapter 2: The Linux System Part 4
Chapter 9: Virtual Memory – Part II
File-System Implementation
ITEC 202 Operating Systems
Structure of Processes
Day 23 Virtual Memory.
Day 24 Virtual Memory.
Day 21 Virtual Memory.
Day 22 Virtual Memory.
Virtual Memory Management
Virtual Memory Chapter 8.
Review.
Memory management, part 3: outline
Overview: File system implementation (cont)
COMP755 Advanced Operating Systems
CSE 542: Operating Systems
Presentation transcript:

1 Memory Management in Representative Operating Systems

CS-550: Memory Management in Representative Operating Systems 2 Memory Management and Virtual Memory Memory management requirements Memory partitioning Paging Segmentation Virtual memory with –Paging –Segmentation –Combined paging and segmentation Virtual memory management policies and strategies

CS-550: Memory Management in Representative Operating Systems 3 UNIX and Solaris Memory Management Evolution –Early implementations of UNIX used variable partitioning and no virtual memory –Current implementations – SVR4 and Solaris – use paged virtual memory Memory management schemes in SVR4 and Solaris –Paging system Allocates page frames in main memory to processes Allocates page frames to disk block buffers –Kernel memory allocator

CS-550: Memory Management in Representative Operating Systems 4 UNIX and Solaris Memory Management (cont.) Paging system –Data structures Page table –One page table per process –One entry for each page in virtual memory for that process Disk block descriptor –Has an entry associated with each page of a process –Each entry describes the disk copy of the virtual page Page frame data table –Describes each frame of real memory –Indexed by frame number Swap-use table –One table for each swap device –One entry for each page on the device

CS-550: Memory Management in Representative Operating Systems 5 UNIX and Solaris Memory Management (cont.)

CS-550: Memory Management in Representative Operating Systems 6 UNIX and Solaris Memory Management (cont.)

CS-550: Memory Management in Representative Operating Systems 7 UNIX and Solaris Memory Management (cont.) Paging system –Page replacement Page frame data table used for page replacement Lists are created within table using pointers (e.g., list of free frames available; when number of frames on this table drops below a threshold, the kernel will steal a number of pages to compensate) Page replacement algorithm in SVR4 is a modified clock policy algorithm, the two-handed clock algorithm –It uses the reference bit in the page table entry for each page in memory that is eligible (not locked) to be swapped out –Bit is set to 0 when page is first brought in and set to 1 when page is referenced for read or write –The front-hand of the algorithm sweeps through the eligible pages and sets reference bits to 1 –The backhand, later, sweeps same list and checks the referenced bit: if 0, page is placed on the list to be paged out –Parameters: Scanrate and Handspead

CS-550: Memory Management in Representative Operating Systems 8 UNIX and Solaris Memory Management (cont.) Kernel memory allocator –Requirement Kernel generates and destroys frequently small tables and buffers (e.g, file descriptor blocks) which require dynamic memory allocation These tables and buffers are much smaller than typical machine page size: paging mechanism would be inefficient –Solution: SVR4 uses the lazy buddy system Observation: demand for blocks of particular size varies slowly in time Solution: defer coalescing blocks until it seems likely that it is needed and then coalesce as many blocks as possible Strategy: try to maintain a pool of locally free blocks and only invoke coalescing if the number of free blocks exceeds a threshold Criterion for coalescing: the number of locally free blocks of a given size should not exceed the number of allocated blocks of that size

CS-550: Memory Management in Representative Operating Systems 9 Linux Memory Management Characteristics –Shares many characteristics from the other UNIX implementations –Has some unique features and is quite complex Linux virtual memory –Virtual memory addressing Three-level page table structure –Page directory: one per active process, size of one page –Page middle directory –Page table Virtual address space has four fields –Index into the page directory –Index into the page middle directory –Index into the page table –Offset within the selected page of memory Page table structure is platform independent and was designed to accommodate the 64-bi Alpha processor

CS-550: Memory Management in Representative Operating Systems 10 Linux Memory Management (cont.) Linux virtual memory (cont.) –Virtual memory addressing (cont.) Page allocation –A buddy system is used to improve the efficiency of reading and writing contiguous blocks of pages mapped into contiguous blocks of page frames –Kernel maintains a list of contiguous page frame groups of fixed size: 1, 2, 4, 8, 16, 32 page frames –For allocation and deallocation of pages in main memory, the available groups are split and merged using the buddy system Page replacement algorithm –Variation of the clock algorithm: least frequently used policy –The use bit is replaced with an 8-bit age variable –Age variable incremented each time page is accessed –Periodically, Linux sweeps through the global page pool and decrements the age variable for each page –A page with a low age variable is a candidate for replacement

CS-550: Memory Management in Representative Operating Systems 11 Linux Memory Management (cont.) Kernel memory allocation –Based on the page allocation mechanism used for virtual memory management –Buddy algorithm is used to allocate and de-allocate kernel memory in units of one or more pages –Since the kernel needs small (smaller than a page) chunks of memory for short intervals,Linux uses slab allocation within an allocated page –Example: on a Pentium/x86 machine page size is 4 Kbytes and chunks can be allocated in sizes 32, 64, 128, 252, 508, 2040, and 4080 bytes –Slab allocator implementation A set of linked lists are maintained, one for each size of chunk Chunks can be split, aggregated, and moved between lists like in the buddy algorithm

CS-550: Memory Management in Representative Operating Systems 12 Windows 2000 Memory Management Characteristics –Designed to operate over a variety of platforms and use page sizes from 4 Kbytes to 64 Kbytes –Current platforms Intel, PowerPC, and MIPS platforms have 4,096 bytes per page DEC Alpha platforms have 8,192 bytes per page W2K virtual address map –2 Gbytes of available virtual address space for user (increased optionally to 3 Gbytes) –2 Gbytes for the operating system (W2K Executive, microkernel, and device drivers)

CS-550: Memory Management in Representative Operating Systems 13 Windows 2000 Memory Management (cont)

CS-550: Memory Management in Representative Operating Systems 14 Windows 2000 Memory Management (cont.) W2K paging –When a process is created, it can use up to 2 Gbytes (minus 128 Kbytes) of virtual space, divided in fixed-size pages –Page states: Available: Pages not currently used by the process Reserved: Set of contiguous pages set aside for the process, but not counted as part of process quota until used. Committed to to process when it needs to write into memory Committed: Pages for which space on the paging file has been set aside (e.g., the disk file used when removing pages from memory) –Resident set management scheme Variable allocation, local scope When process first activated, given a default working set: if process references a page not in memory, one of the resident pages is swapped out Working set of active processes is adjusted as follows: –When memory plentiful, active processes are allowed to grow –When memory becomes scarce, resident sets for each process are reduced