Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

Part IV: Memory Management
Memory Management Today Basic memory management Swapping Kernel memory allocation Next Time Virtual memory.
Allocating Memory.
Memory Management. Managing Memory … The Simplest Case The O/S User Program 0 0xFFF … * Early PCs and Mainframes * Embedded Systems One user program at.
1 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management - 2 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Multiprocessing Memory Management
Chapter 3.1 : Memory Management
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
CMPT 300 Operating System I
Memory Management (continued) CS-3013 C-term Memory Management CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System.
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 ManagementCS-502 Fall Memory Management CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th.
Computer Organization and Architecture
Avishai Wool lecture Introduction to Systems Programming Lecture 6 Memory Management.
1 Chapter 3.1 : Memory Management Storage hierarchy Storage hierarchy Important memory terms Important memory terms Earlier memory allocation schemes Earlier.
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.
Chapter 91 Memory Management Chapter 9   Review of process from source to executable (linking, loading, addressing)   General discussion of memory.
Review of Memory Management, Virtual Memory CS448.
Memory Management By: Omar A. Cruz Salgado ICOM 5007 Sec. 121.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
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 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 – Page 1 of 49CSCI 4717 – Computer Architecture Memory Management Uni-program – memory split into two parts –One for Operating System.
Subject: Operating System.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Operating Systems COMP 4850/CISG 5550 Basic Memory Management Swapping Dr. James Money.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Memory Management Overview.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Mono an multiprogramming.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
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 3-1, 3-2 MEMORY MANAGEMENT. MEMORY HIERARCHY Small amount of expensive, fast, volatile cache Larger amount of still fast, but slower, volatile.
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.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Memory Management One of the most important OS jobs.
Memory Management.
Chapter 2 Memory and process management
From Monoprogramming to multiprogramming with swapping
CSC 322 Operating Systems Concepts Lecture - 12: by
Chapter 9 – Real Memory Organization and Management
William Stallings Computer Organization and Architecture
Main Memory Management
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.
So far… Text RO …. printf() RW link printf Linking, loading
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.
CSE 451: Operating Systems Autumn 2005 Memory Management
Memory Management (1).
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
COMP755 Advanced Operating Systems
Presentation transcript:

Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”

Memory hierarchy RegistersCacheRAM How can the OS help processes share RAM? How can the OS help processes share RAM? Hard disk CD, DVD Tape

Basic memory management Types: 1. Moves process back and forth between main memory and disk (swapping and paging). 2. Those that do not (move processes back and forth).

Basic memory management Monoprogramming w/out swapping or paging only 1 programs runs at a time only 1 programs runs at a time OS is also in memory OS is also in memory load  execute to completion  load next Early mainframes Embedded systems, palmtop computers MS DOS

Basic memory management Multiprogramming w/ fixed partitions Divide memory into n fixed size partitions Divide memory into n fixed size partitions All the same size or some larger, some smaller? Single job queue or multiple job queues?

Basic memory management Multiprogramming w/ fixed partitions issues: 1. Unused partition space is wasted. 2. Multiple queues partitions (often larger) may go unused partitions (often larger) may go unused 3. Single queue Large partitions wasted on small jobs Large partitions wasted on small jobs Or if we favor larger jobs, smaller (often interactive) jobs may be starved. Or if we favor larger jobs, smaller (often interactive) jobs may be starved.

Modeling multiprogramming Let p be the probability that a process waits on I/O. Given n such processes, what is the probability that all n processes are waiting on I/O at the same time? p 1 * p 2 * … * p n = p n p 1 * p 2 * … * p n = p n Therefore, for a given p and n, the CPU utilization = 1-p n (Assumes that all n processes are independent but that is not the case for 1 CPU or if we need exclusive I/O! But we’ll employ the “ostrich algorithm and live with it!)

CPU utilization Given that we have enough memory to support 10 processes and each process spends 80% of its time doing I/O, what’s CPU utilization?

CPU utilization Given that we have enough memory to support 10 processes and each process spends 80% of its time doing I/O, what’s CPU utilization? Given n=10, p=0.80 Given n=10, p=0.80 So CPU utilization = So CPU utilization = (about 0.90 or 90%) (about 0.90 or 90%)

CPU utilization

Suppose we have 32MB. The OS uses 16MB. Each user program uses 4MB and has an 80% I/O wait. How many users, n, can we support in memory at once? Given the above n, what is our CPU utilization?

CPU utilization Suppose we have 32MB. The OS uses 16MB. Each user program uses 4MB and has an 80% I/O wait. How many users, n, can we support in memory at once? 4 = (32-16)/4 4 = (32-16)/4 Given the above n, what is our CPU utilization? ( )=0.60 or 60% ( )=0.60 or 60% What is our CPU utilization if we add 16M?

CPU utilization Now we have 48MB. The OS uses 16MB. Each user program uses 4MB and has an 80% I/O wait. How many users, n, can we support in memory at once? 8 = (48-16)/4 8 = (48-16)/4 Given the above n, what is our CPU utilization? ( )=0.83 or 83% ( )=0.83 or 83% So we went from 60% to 83% with 16M more. So we went from 60% to 83% with 16M more. What is our CPU utilization if we add 16M?

CPU utilization Now we have 64MB. The OS uses 16MB. Each user program uses 4MB and has an 80% I/O wait. How many users, n, can we support in memory at once? 12 = (64-16)/4 12 = (64-16)/4 Given the above n, what is our CPU utilization? ( )=0.93 or 93% ( )=0.93 or 93% So we went from 83% to 93% with 16M more. So we went from 83% to 93% with 16M more.

Relocation and protection Relocation – a program should be able to execute in any partition of memory (starting at any physical address) Protection – a process should have read/write access to data memory, read access to its own code memory, read access to some parts of the OS, and no access to other parts Base/limit registers = early method

swapping We want more processes than memory! 2 solutions: 1. Swapping 1.bring in each process in its entirety 2.run it for a while 3.put it back on disk 2. Virtual memory (paging)

swapping Memory compaction (like disk fragmentation) memory may become fragmented into little pieces so we may have to more all processes down into lowest memory. memory may become fragmented into little pieces so we may have to more all processes down into lowest memory.

swapping

swapping What if the memory needs of a process changes over time?

swapping Memory management – How do we keep track of what memory is being used and what memory is available? 1. Bitmaps 2. Linked lists

Swapping: memory management w/ bitmaps Divide memory into equal size allocation units (e. g., 1K “chunks”). Bit = 0 means the chunk is free; bit = 1 means that chunk is in use. Small chunks -> large bitmap Large chunks -> small bitmap Large chunks -> waste Large chunks -> waste

Swapping: memory management w/ linked lists Linked list of allocated and free memory segments. Segment = memory used by process or hole (free memory) between processes Segment = memory used by process or hole (free memory) between processes Usually sorted by address Usually sorted by address May be implemented as one list (of both used and free) as as two separate lists May be implemented as one list (of both used and free) as as two separate lists

Swapping: memory management w/ linked lists Allocation methods: 1. First fit – simple, fast; leaves large holes 2. Next fit – continue searching from where ff last left off 3. Best fit – slower than ff; wastes memory = leaves many small, useless holes 4. Worst fit – not very good 5. Quick fit – keeps lists with common hole sizes

Virtual memory