Review of Memory Management, Virtual Memory CS448.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2009, Prentice.
Memory Management Norman White Stern School of Business.
Chapter 7 Memory Management
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Memory Design Example. Selecting Memory Chip Selecting SRAM Memory Chip.
Operating System Support Focus on Architecture
Multiprocessing Memory Management
Operating System Support Focus on Architecture
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management 2010.
Chapter 8 Operating System Support (Continued)
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
Chapter 8 Operating System Support
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
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.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory Management Chapter 5.
Computer Organization and Architecture
Virtual Memory I Chapter 8.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Computer Organization and Architecture Operating System Support Chapter 8.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Memory Management – Page 1 of 49CSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Memory Management Reading: Stallings, Sections.
Operating Systems Chapter 8
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
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 – Page 1 of 49CSCI 4717 – Computer Architecture Memory Management Uni-program – memory split into two parts –One for Operating System.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Chapter 9 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
Subject: Operating System.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
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.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
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.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management – Page 1CSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Memory Management *** Modified – look for Reading:
Computer Architecture Chapter (8): Operating System Support
SLC/VER1.0/OS CONCEPTS/OCT'99
Chapter 8 Operating System Support
William Stallings Computer Organization and Architecture
Virtual Memory Chapter 8.
Main Memory Management
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.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
William Stallings Computer Organization and Architecture 8th Edition
Operating Systems.
Computer Architecture
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
CSCI 4717/5717 Computer Architecture
William Stallings Computer Organization and Architecture 8th Edition
Operating Systems: Internals and Design Principles, 6/E
Presentation transcript:

Review of Memory Management, Virtual Memory CS448

Memory Management In a Multiprogramming System –Each user could run many processes –Each process has access to some section of memory –Memory requirements of the processes might exceed that of actual physical memory –Operating System plus the hardware has the task of managing memory Options –Swapping –Partitioning –Paging

Swapping Problem: I/O is so slow compared with CPU that even in multi-programming systems, the CPU can be idle most of the time Solutions: –Increase main memory Expensive Leads to larger programs –Swapping

What is Swapping? Long term queue of processes stored on disk Processes “swapped” in as space becomes available As a process completes it is moved out of main memory If none of the processes in memory are ready (i.e. all I/O blocked) –Swap out a blocked process to intermediate queue –Swap in a ready process or a new process But… –Swapping is an I/O process... Potential to make things worse with big processes –Doesn’t allow us to execute programs larger than physical memory

Partitioning Splitting memory into sections to allocate to processes (including Operating System) Fixed-sized partitions –May not be equal size –Process is fitted into smallest hole that will take it (best fit) –Some wasted memory –Leads to variable sized partitions

Fixed Partitioning

Variable Sized Partitions (1) Allocate exactly the required memory to a process This leads to a hole at the end of memory, too small to use –Only one small hole - less waste When all processes are blocked (or time-slice is up), swap out a process and bring in another New process may be smaller than swapped out process Another hole

Variable Sized Partitions (2) Eventually have lots of holes (fragmentation) Solutions: –Coalesce - Join adjacent holes into one large hole –Compaction - From time to time go through memory and move all hole into one free block (c.f. disk de- fragmentation) –Time consuming!

Effect of Dynamic Partitioning Swap out 2 Make hole Add back 2 in a different memory location! Need logical addresses

Relocation No guarantee that process will load into the same place in memory Instructions contain addresses –Locations of data –Addresses for instructions (branching) Logical address - relative to beginning of program Physical address - actual location in memory (this time) Automatic conversion using base address

Paging Most common technique used today, superior to the previous two schemes Split memory into equal sized, small chunks –Called pages, frames, or blocks Split programs (processes) into equal sized pages Allocate some number of page frames to a process Operating System maintains list of free frames A process does not require contiguous page frames –Use page table to keep track –With virtual memory, pages could be on disk

Allocation of Pages

Allocation of Free Frames Each process given their own Page Table. Here, add Process A: Free Frame List Process A: Page 0 Page 1 Page 2 Page 3 … 13Free 14Free 15Free 16Used 17Used 18Free 19Used 20Free 21Used … Memory Frames Free Frame List 20 Process A: Page 0 : 13 Page 1 : 14 Page 2 : 15 Page 3 : 18 … 13A: Page 0 14A : Page 1 15A : Page 2 16Used 17Used 18A : Page 3 19Used 20Free 21Used … Memory Frames

Logical and Physical Addresses - Paging

Virtual Memory Demand paging –Do not require all pages of a process in memory –Bring in pages as required Page fault –Required page is not in memory –Operating System must swap in required page –May need to swap out a page to make space –Select page to throw out based on recent history Just like caching! –Needless to say this is very time consuming! Good thing we can process-switch to something else that is hopefully ready to do work, while we wait for a page to load from disk (many cycles)

Virtual Addressing Present? Page in Memory Disk Address Page # for Process

Thrashing What if we have a large number of processes running with too little memory? –Operating System spends all its time swapping –Little or no real work is done All the time is spent in overhead in process switching Could happen if you fork off too many processes uncontrollably –Disk light is on all the time Solutions –Good page replacement algorithms –Reduce number of processes running –Fit more memory

Bonus We do not need all of a process in memory for it to run We can swap in pages as required So - we can now run processes that are bigger than total memory available! Main memory is called real memory User/programmer sees much bigger memory - virtual memory

Problems with Virtual Memory Each process can see a big virtual memory –This means each process has its own Page Table –Page table can be big E.g. Power PC has 32 bit virtual addresses, with 4K page size 2 12 = 4K, leaves 2 32 / 2 12 = 2 20 pages per process –Storing 2 20 entries per process takes a lot of memory –Actually only 2 16, because we’ll use 4 bits for a segment Solutions –Store page table itself in virtual memory; page table could be swapped in and out –Two-level schemes –Inverted schemes

Inverted Page Table Structure ID+ Table for Real Memory Pages - Stored in fixed proportion of real memory Not one per virtual page Use hashing to lookup frame # Add ID based on PID

Translation Lookaside Buffer Virtual memory reference can cause two physical memory accesses –Fetch appropriate page table entry –Fetch desired data –Could double memory access time Solution –Create a special cache for page table entries –Called the TLB (Translation Lookaside Buffer) –Functions just like a memory cache Contains page table entries most recently used Complicates things even more for just a single memory reference –Look to see if virtual address is in the TLB »If yes, use it. If not, we must fetch it from memory or disk –Decode the virtual address via the Page Table to a physical address –Send the physical address to the data cache to see if it’s in the cache »All our usual stuff with cache hits/misses

Segmentation Paging is not (usually) visible to the programmer Segmentation is visible to the programmer Usually different segments allocated to program and data –E.g., a segmented memory might be used to allow two users to share the same word processor code, with different data spaces May be a number of program and data segments

Segmentation Example Pages Means a virtual memory address with segmentation is split up into segment, page, offset Allows sharing among processes, protection of segments (also where memory faults can be generated), growing of data structures if OS increases the segment size