Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Memory.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Basic Memory Management Monoprogramming Protection Swapping Overlaying OS space User space.
Part IV: Memory Management
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 13: Main Memory (Chapter 8)
Memory Management Chapter 7.
Fixed/Variable Partitioning
Allocating Memory.
CS 311 – Lecture 21 Outline Memory management in UNIX
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
CS 104 Introduction to Computer Science and Graphics Problems
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.
Operating System Concepts
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
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.
Chapter 8 Main Memory Bernard Chen Spring Objectives To provide a detailed description of various ways of organizing memory hardware To discuss.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Operating Systems Chapter 8
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
1 Memory Management Chapter Basic memory management 4.2 Swapping (εναλλαγή) 4.3 Virtual memory (εικονική/ιδεατή μνήμη) 4.4 Page replacement algorithms.
Chapter 4 Memory Management.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
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.
Subject: Operating System.
Chapter 10 Memory Management Introduction Process must be loaded into memory before being executed. Input queue – collection of processes on the.
Chapter 4 Memory Management Virtual Memory.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
CS 241 Spring 2007 System Programming 1 Introduction to Memory Management Lecture 28 Lawrence Angrave/Klara Nahrstedt.
Memory Management Operating Systems CS550. Memory Manager Memory manager - manages allocation and de-allocation of main memory Plays significant impact.
Memory Management. Introduction To improve both the utilization of the CPU and the speed of its response to users, the computer must keep several processes.
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.
Mid2 Revision & VM Prof. Sin-Min Lee. Classification of Digital Circuits Combinational. – Output depends only on current input values. Sequential. –Output.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1 Memory management & paging.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
Midterm 3 Revision Prof. Sin-Min Lee Department of Computer Science.
Memory Management Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only storage.
Midterm 3 Revision 2 Prof. Sin-Min Lee Department of Computer Science.
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.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Pipes and Fifos.
Memory.
Memory Management.
Prof. Sin-Min Lee Department of Computer Science
Main Memory Management
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Operating System Concepts
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Multistep Processing of a User Program
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Management-I 1.
Chapter3 Memory Management Techniques
Main Memory Background Swapping Contiguous Allocation Paging
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
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.
Page Main Memory.
Presentation transcript:

Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Memory

Copyright ©: Nahrstedt, Angrave, Abdelzaher 2 Memory Allocation Compile for overlays Compile for fixed Partitions Separate queue per partition Single queue Relocation and variable partitions Dynamic contiguous allocation (bit maps versus linked lists) Fragmentation issues Swapping Paging

Copyright ©: Nahrstedt, Angrave, Abdelzaher 3 Overlays Overlay Manager Overlay Area Main Program Overlay 1 Overlay 2 Overlay 3 Secondary Storage Overlay 1Overlay 2Overlay 3Overlay 1 0K 5k 7k 12k

Copyright ©: Nahrstedt, Angrave, Abdelzaher 4 Multiprogramming with Fixed Partitions Divide memory into n (possible unequal) partitions. Problem: Fragmentation Free Space 0k 4k 16k 64k 128k

Copyright ©: Nahrstedt, Angrave, Abdelzaher 5 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated)

Copyright ©: Nahrstedt, Angrave, Abdelzaher 6 Fixed Partition Allocation Implementation Issues Separate input queue for each partition Requires sorting the incoming jobs and putting them into separate queues Inefficient utilization of memory when the queue for a large partition is empty but the queue for a small partition is full. Small jobs have to wait to get into memory even though plenty of memory is free. One single input queue for all partitions. Allocate a partition where the job fits in. Best Fit Worst Fit First Fit

Copyright ©: Nahrstedt, Angrave, Abdelzaher 7 Relocation Correct starting address when a program starts in memory Different jobs will run at different addresses When a program is linked, the linker must know at what address the program will begin in memory. Logical addresses, Virtual addresses Logical address space, range (0 to max) Physical addresses, Physical address space range (R+0 to R+max) for base value R. User program never sees the real physical addresses Memory-management unit (MMU) map virtual to physical addresses. Relocation register Mapping requires hardware (MMU) with the base register

Copyright ©: Nahrstedt, Angrave, Abdelzaher 8 Relocation Register Memory Base Register CPU Instruction Address + BA MA MA+BA Physical Address Logical Address

Copyright ©: Nahrstedt, Angrave, Abdelzaher 9 Question 1 - Protection Problem: How to prevent a malicious process to write or jump into other user's or OS partitions Solution: Base bounds registers

Copyright ©: Nahrstedt, Angrave, Abdelzaher 10 Base Bounds Registers Memory Bounds RegisterBase Register CPU Address <+ Memory Address MA Logical Address LA Physical Address PA Fault Base Address Limit Address MA+BA Base Address BA

Copyright ©: Nahrstedt, Angrave, Abdelzaher 11 Contiguous Allocation and Variable 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

Copyright ©: Nahrstedt, Angrave, Abdelzaher 12 More on Memory Management with Linked Lists Four neighbor combinations for the terminating process X

Copyright ©: Nahrstedt, Angrave, Abdelzaher 13 Contiguous Variable Partition Allocation schemes Bitmap and link list Which one occupies more space? Depending on the individual memory allocation scenario. In most cases, bitmap usually occupies more space. Which one is faster reclaim freed space? On average, bitmap is faster because it just needs to set the corresponding bits Which one is faster to find a free hole? On average, a link list is faster because we can link all free holes together

Copyright ©: Nahrstedt, Angrave, Abdelzaher 14 Storage Placement Strategies Best fit Use the hole whose size is equal to the need, or if none is equal, the whole that is larger but closest in size. Rationale? First fit Use the first available hole whose size is sufficient to meet the need Rationale? Worst fit Use the largest available hole Rationale?

Copyright ©: Nahrstedt, Angrave, Abdelzaher 15 Storage Placement Strategies Every placement strategy has its own problem Best fit Creates small holes that cant be used Worst Fit Gets rid of large holes making it difficult to run large programs First Fit Creates average size holes

Copyright ©: Nahrstedt, Angrave, Abdelzaher 16 How Bad Is Fragmentation? Statistical arguments - Random sizes First-fit Given N allocated blocks 0.5  N blocks will be lost because of fragmentation Known as 50% RULE

Copyright ©: Nahrstedt, Angrave, Abdelzaher 17 Solve Fragmentation w. Compaction MonitorJob 3 Free Job 5Job 6Job 7Job 8 5 MonitorJob 3 Free Job 5Job 6Job 7Job 8 6 MonitorJob 3 Free Job 5Job 6Job 7Job 8 7 MonitorJob 3 Free Job 5Job 6Job 7Job 8 8 MonitorJob 3 Free Job 5Job 6Job 7Job 8 9

Copyright ©: Nahrstedt, Angrave, Abdelzaher 18 Storage Management Problems Fixed partitions suffer from internal fragmentation Variable partitions suffer from external fragmentation Compaction suffers from overhead

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

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

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

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

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

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

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

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

Copyright ©: Nahrstedt, Angrave, Abdelzaher 27 Paging Provide user with virtual memory that is as big as user needs Store virtual memory on disk Cache parts of virtual memory being used in real memory Load and store cached virtual memory without user program intervention

Copyright ©: Nahrstedt, Angrave, Abdelzaher 28 Benefits of Virtual Memory Use secondary storage($) Extend DRAM($$$) with reasonable performance Protection Programs do not step over each other Convenience Flat address space Programs have the same view of the world Load and store cached virtual memory without user program intervention Reduce fragmentation: make cacheable units all the same size (page) Remove memory deadlock possibilities: permit pre-emption of real memory

Copyright ©: Nahrstedt, Angrave, Abdelzaher 29 Paging Request Disk Cache Virtual Memory Stored on Disk Page Table VMFrame Real Memory Request Address within Virtual Memory Page 3

Copyright ©: Nahrstedt, Angrave, Abdelzaher 30 Paging Disk Cache Virtual Memory Stored on Disk Page Table VMFrame Real Memory Request Address within Virtual Memory Page 1

Copyright ©: Nahrstedt, Angrave, Abdelzaher 31 Paging Disk Cache Virtual Memory Stored on Disk Page Table VMFrame Real Memory Request Address within Virtual Memory Page 6

Copyright ©: Nahrstedt, Angrave, Abdelzaher 32 Paging Disk Cache Virtual Memory Stored on Disk Page Table VMFrame Real Memory Request Address within Virtual Memory Page 2 2

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

Copyright ©: Nahrstedt, Angrave, Abdelzaher 34 Paging Disk Cache Virtual Memory Stored on Disk Page Table VM Frame Real Memory 2 Load Virtual Memory Page 8 to cache 8

Copyright ©: Nahrstedt, Angrave, Abdelzaher 35 Page Mapping Hardware Contents(P,D) Contents(F,D) PD FD P-> F Page Table Virtual Memory Physical Memory Virtual Address (P,D) Physical Address (F,D) P F D D P

Copyright ©: Nahrstedt, Angrave, Abdelzaher 36 Page Mapping Hardware Contents(4006) Contents(5006) > Page Table Virtual Memory Physical Memory Virtual Address (004006) Physical Address (F,D)

Copyright ©: Nahrstedt, Angrave, Abdelzaher 37 Paging Issues size of page is 2 n, usually 512, 1k, 2k, 4k, or 8k E.g. 32 bit VM address may have 2 20 (1 meg) pages with 4k (2 12 ) bytes per page Rational?

Copyright ©: Nahrstedt, Angrave, Abdelzaher 38 Paging Issues 2 20 (1 meg) 32 bit page entries take 2 22 bytes (4 meg) page frames must map into real memory

Copyright ©: Nahrstedt, Angrave, Abdelzaher 39 Paging Issues Question Physical memory size: 32 MB (2^25 ) Page size 4K bytes How many pages? 2^13 Page Table base register must be changed for context switch Why? Different page table NO external fragmentation Internal fragmentation on last page ONLY

Copyright ©: Nahrstedt, Angrave, Abdelzaher 40 Paging - Caching the Page Table Can cache page table in registers and keep page table in memory at location given by a page table base register Page table base register changed at context switch time

Copyright ©: Nahrstedt, Angrave, Abdelzaher 41 Paging Implementation Issues Caching scheme can use associative registers, look-aside memory or content-addressable memory TLB Page address cache (TLB) hit ratio: percentage of time page found in associative memory If not found in associative memory, must load from page tables: requires additional memory reference

Copyright ©: Nahrstedt, Angrave, Abdelzaher 42 Page Mapping Hardware PD FD P-> F Page Table Virtual Memory Address (P,D) Physical Address (F,D) P Associative Look Up PF First

Copyright ©: Nahrstedt, Angrave, Abdelzaher 43 Page Mapping Hardware > Page Table Virtual Memory Address (P,D) Physical Address (F,D) 4 Associative Look Up First Table organized by LRU 49

Copyright ©: Nahrstedt, Angrave, Abdelzaher 44 Page Mapping Hardware > Page Table Virtual Memory Address (P,D) Physical Address (F,D) 4 Associative Look Up First Table organized by LRU