Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1 Memory management & paging.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
CSS430 Memory Management Textbook Ch8
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 13: Main Memory (Chapter 8)
Memory Management Chapter 7.
Fixed/Variable Partitioning
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Allocating Memory.
Chapter 7 Memory Management
CS 311 – Lecture 21 Outline Memory management in UNIX
1 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.
Chapter 7 Memory Management
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
Memory Management.
Memory Management Chapter 7 B.Ramamurthy. Memory Management Subdividing memory to accommodate multiple processes Memory needs to allocated efficiently.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory Management Chapter 5.
Memory Management Five Requirements for Memory Management to satisfy: –Relocation Users generally don’t know where they will be placed in main memory May.
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.
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Example of a Resource Allocation Graph CS1252-OPERATING SYSTEM UNIT III1.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 32 Paging Read Ch. 9.4.
Operating System 7 MEMORY MANAGEMENT. MEMORY MANAGEMENT REQUIREMENTS.
Memory Management Chapter 7.
Chapter 7 Memory Management
Chapter 7 Memory Management Seventh Edition William Stallings Operating Systems: Internals and Design Principles.
Chapter 4 Memory Management.
Memory Management 1 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
1 Address Translation Memory Allocation –Linked lists –Bit maps Options for managing memory –Base and Bound –Segmentation –Paging Paged page tables Inverted.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Virtual Memory 1 1.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Memory.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management Chapter 5 Advanced Operating System.
1 Memory Management n In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main 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 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. 
Memory.
Memory Management.
Memory Allocation The main memory must accommodate both:
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
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.
So far… Text RO …. printf() RW link printf Linking, loading
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 32 Syed Mansoor Sarwar
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2005 Memory Management
Operating System Chapter 7. Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Page Main Memory.
Presentation transcript:

Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1 Memory management & paging

Copyright ©: Nahrstedt, Angrave, Abdelzaher 2 More on dynamic partitions: Bit Maps versus Linked Lists Part of memory with 5 processes, 3 holes tick marks show allocation units shaded regions are free Corresponding bit map & linked list

Copyright ©: Nahrstedt, Angrave, Abdelzaher 3 Four neighbor combinations for the terminating process X More on dynamic partitions: Bit Maps versus Linked Lists

Copyright ©: Nahrstedt, Angrave, Abdelzaher 4 Bitmap and linked list Which one occupies more space? Depends on the individual memory allocation scenario. In most cases, bitmap usually needs more space. In terms of processing time, on average bitmap is faster because it just needs to update the corresponding bits Which one is faster to find a free hole? On average, linked list is faster because we can link all free holes together More on dynamic partitions: Bit Maps versus Linked Lists

Copyright ©: Nahrstedt, Angrave, Abdelzaher 5 Storage Placement Algorithms Best fit Use smallest free space equal to or larger than the need Rationale? First fit Use the first free space found that is large enough to meet the need Rationale? Worst fit Use the largest available free space Rationale?

Copyright ©: Nahrstedt, Angrave, Abdelzaher 6 Each strategy has problems Best fit Creates small free spaces that can’t be used Worst Fit Removes large free spaces, so large programs may not fit First Fit Creates average size free spaces Storage Placement Algorithms

Copyright ©: Nahrstedt, Angrave, Abdelzaher 7 Mentioned approaches can perform better or worse depending on exact sequence of process arrivals and size of those processes First-fit is very simple and usually performs very well Surprisingly best-fit is usually the worst performer: it guarantees that smallest amount of memory is always wasted but memory is quickly fragmented in pieces too small to satisfy further requests Storage Placement Algorithms

Copyright ©: Nahrstedt, Angrave, Abdelzaher 8 How Bad Is Fragmentation? Statistical argument: processes have random sizes Assume to use first-fit and N blocks are allocated 0.5  N blocks will be wasted because of internal fragmentation Known as 50% RULE

Copyright ©: Nahrstedt, Angrave, Abdelzaher 9 Dynamic partitions: solve fragmentation with compaction MonitorJob 3 Free Job 5Job 6Job 7Job 8 1 MonitorJob 3 Free Job 5Job 6Job 7Job 8 2 MonitorJob 3 Free Job 5Job 6Job 7Job 8 3 MonitorJob 3 Free Job 5Job 6Job 7Job 8 4 MonitorJob 3 Free Job 5Job 6Job 7Job 8 5

Copyright ©: Nahrstedt, Angrave, Abdelzaher 10 Fixed vs dynamic partitions Fixed partitions suffer from internal fragmentation Dynamic partitions suffer from external fragmentation Compaction suffers from overhead

Copyright ©: Nahrstedt, Angrave, Abdelzaher 11 Question What if there are more processes than what could fit into the memory?

Copyright ©: Nahrstedt, Angrave, Abdelzaher 12 Swapping Monitor Disk User Partition

Copyright ©: Nahrstedt, Angrave, Abdelzaher 13 Swapping Monitor Disk User 1 User Partition

Copyright ©: Nahrstedt, Angrave, Abdelzaher 14 Swapping Monitor User 1 Disk User 1 User Partition

Copyright ©: Nahrstedt, Angrave, Abdelzaher 15 Swapping Monitor User 2 User 1 Disk User 1 User Partition

Copyright ©: Nahrstedt, Angrave, Abdelzaher 16 Swapping Monitor Disk User 2 User Partition User 1

Copyright ©: Nahrstedt, Angrave, Abdelzaher 17 Swapping Monitor Disk User 2 User Partition User 1

Copyright ©: Nahrstedt, Angrave, Abdelzaher 18 Swapping Monitor Disk User 1 User 2 User Partition User 1

Copyright ©: Nahrstedt, Angrave, Abdelzaher 19 Both fixed and dynamic size partitioning are inefficient; in fact fixed partitioning suffers internal fragmentation while dynamic partitioning suffers external fragmentation Suppose to partition physical main memory in small equal-size chunks (frames) Suppose each process memory is also divided into small fixed-size chunks (pages) of the same size Pages of a process can be mapped to available frames of memory We would like to allocate non-contiguous frames to a process can we do that? if this is the case, is the system suffering internal or external fragmentation? Paging

Copyright ©: Nahrstedt, Angrave, Abdelzaher 20 Suppose to partition physical main memory in small equal-size chunks (frames) Suppose each process memory is also divided into small fixed-size chunks (pages) of the same size Pages of a process can be mapped to available frames of memory We would like to allocate non-contiguous frames to a process can we do that? if this is the case, is the system suffering internal or external fragmentation? We can implement such a scheme as follows: The programmer uses a contiguous logical address space (Virtual Memory divided in pages) System uses a process page table to identify page frame mapping for each process Translation from logical to physical addressing is performed by CPU at run-time A logical address is composed of (page #, offset); the processor uses active process page table to produce a physical address (frame #, offset) Paging

31234 Disk Main Memory Virtual Memory Stored on Disk Page Table VMFrame Main Memory Request Page 3 Paging

Disk Main Memory Virtual Memory Stored on Disk Page Table VMFrame Main Memory Request Page 1 Paging

Disk Main Memory Virtual Memory Stored on Disk Page Table VMFrame Main Memory Request Page 6 Paging

Disk Main Memory Virtual Memory Stored on Disk Page Table VMFrame Main Memory Request Page 2 2 Paging

Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk Virtual Memory Stored on Disk Page Table VMFrame Main Memory Store Virtual Memory Page 1 to disk 2 Request Address within Virtual Memory 8 Paging

Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk Virtual Memory Stored on Disk Page Table VM Frame Main Memory 2 Load Virtual Memory Page 8 to main memory 8 Paging

Contents(P,D) Contents(F,D) PDFD P→F Page Table Physical Memory Virtual Address (P,D) Physical Address (F,D) P F D D P Virtual Memory Page Mapping Hardware

Contents(3006) Contents(4006) →43→ Page Table Virtual Memory Physical Memory Virtual Address (004006) Physical Address (F,D) Page size 1000 Number of Possible Virtual Pages 1000

Page Fault If CPU tries to access a virtual page that is not mapped into any memory frame, a page fault is triggered. Page fault handler (in OS’s VM subsystem) Find if there is any free memory frame available If not, evict some resident page to disk (swapping space) Allocate a free memory frame Load the faulted virtual page to the prepared memory frame Update the page table

More about Paging It is important to use a page size that is power of 2: It is quite easy to implement a hw function that performs run-time address translation Page size is 2 n usually 512 bytes, 1 KB, 2 KB, 4 KB, or 8 KB E.g., 32 bit VM address may have 2 20 (1M) pages with 4k (2 12 ) bytes per page Page table: Assuming each page table entry (PTE) requires 4bytes, 2 20 pages take 2 22 bytes (4 MB) The page table of active process must be resident in main memory Page Table base register must be changed for context switch No external fragmentation; internal fragmentation on last page only