Memory Management One of the most important OS jobs.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Memory management In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. Memory management is achieved.
Chapter 6: Memory Management
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 Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2009, Prentice.
OS Fall’02 Memory Management Operating Systems Fall 2002.
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:
Chapter 3.1 : 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.
Chapter 7 Memory Management
1 Chapter 3.1 : Memory Management Storage hierarchy Storage hierarchy Important memory terms Important memory terms Earlier memory allocation schemes Earlier.
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Memory Allocation CS Introduction to Operating Systems.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Memory Management Chapter 7.
Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Dr.
1. Memory Manager 2 Memory Management In an environment that supports dynamic memory allocation, the memory manager must keep a record of the usage of.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
CY2003 Computer Systems Lecture 09 Memory Management.
Chapter 4 Memory Management.
Memory Management Chapter 7.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
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.
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
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
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.
MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. 
Memory Management Chapter 7.
Chapter 7 Memory Management
Memory Management Chapter 7.
Memory Management.
ITEC 202 Operating Systems
Chapter 2 Memory and process management
From Monoprogramming to multiprogramming with swapping
Memory Allocation The main memory must accommodate both:
CSC 322 Operating Systems Concepts Lecture - 12: by
Chapter 9 – Real Memory Organization and Management
Main Memory Management
Module IV Memory Organization.
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
CS Introduction to Operating Systems
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.
Operating System Chapter 7. Memory Management
Memory Management (1).
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
Chapter 7 Memory Management
Page Main Memory.
Presentation transcript:

Memory Management One of the most important OS jobs. Review memory hierarchy – sizes, speed, cost Growing memories -> growing programs need for swapping and paging The simplest way to use memory is to have one program in memory sharing it with the OS. No swapping or paging. We want multiprogramming – have more than one program in memory at a time.

Memory Management First idea is to divide memory into fixed sized chunks (partitions). The partitions may be equal in size or be of different sizes. A program is given one of the slots and the rest of the partition is wasted. Put it into smallest chunk it will fit into. Single queue of all processes is better than a queue for each size.

Memory Management FIFO vs. pick largest job to not waste memory (poor for small jobs). CPU utilization = 1 – p^n (p = time process waits for I/O, n = degree of multiprogramming). More processes = more efficient use of cpu.

Memory Management Absolute (real) memory address vs. relative memory address. Relocation problem. Programs start at address 0 + have offset. Also must protect address space from other programs.

Memory Management If there isn't enough RAM to hold all the processes, secondary memory + swapping can be used. With swapping whole processes move back and forth between RAM and disk. May be brought back into a different place in memory. Use variable length partitions for better memory utilization. May get many small holes in memory - do memory compaction (slow)

Memory Management How much memory should be allocated to a process? - Fixed size – give exact amount needed - Growth and shrinking - grow into a hole, or have to be moved or swap somebody out. - allocate some space to allow growth. Need a way to keep track of allocated memory (+ to which process) + free memory.

Memory Management Bit maps are one way to keep track of allocated and free memory. - A 1 indicates used and a 0 unused. - Each bit represents one allocation unit (4 bytes, 8 bytes). Linked lists are another way to keep track of memory.

Memory Management Need an algorithm to decide which hole to give to a process. Four fit algorithms. - First Fit – give process first hole in list that is big enough. Break it into two parts (process and a smaller hole). Fast. - Next Fit – Similar to First fit except instead of searching from beginning start where left off. Performs slightly worse than first fit.

Memory Management - Best Fit – Find the smallest hole that will work. Slower than first fit. Wastes more memory because creates small holes. - Worst Fit – Use biggest hole and leave the biggest possible new hole. Doesn't work well in simulation. Another idea is Quick Fit. Have lists of more commonly requested sizes. Can find a good size hole fast. Merging free memory back is hard.

Memory Management Data Structure Thoughts - One list with both processes and holes - slower to find a hole - faster to free up memory. - Two lists – one for processes and one for holes. - can order hole list and speed up best fit. - harder to reallocate. Any other ideas?

The Buddy System Memory blocks are available of size 2k, L <= k <= U 2L = smallest size block allowed 2U = largest block allocated (entire available memory) Start by considering available memory as one block. Then break it down into two buddies of equal size. Continue until smallest block needed for process is created or found. (think binary search).

The Buddy System When memory is released empty buddies can be merged back into a single block. Two free blocks can only be combined if they are buddies, and buddies have addresses that differ only in one bit. Two one-byte blocks are buddies iff they differ in the last bit, two two byte blocks are buddies iff they differ in the second to last bit and so on. (Go over an example)

Buddy System Example Start off with 1 MB to manage 1 MB A requests 100k A=128k, 128k free, 256k free, 512k free B requests 240k A=128k, 128k free, B=256k, 512k free C requests 64k A=128k, C=64k, 64k free, B=256k, 512k free

Buddy System Example D requests 256k A=128k,C=64k, 64k free, B=256k,D=256k, 256k free Release B A=128k,C=64k, 64k free,256k free,D=256k, 256k free Release A 128k free,C=64k,64k free,256k free,D=256k,256k free E requests 75k E=128k,C=64k,64k free,256k free,D=256k,256k free

E=128k,128k free,256k free, D=256k,256k free Buddy System Example Release C E=128k,128k free,256k free, D=256k,256k free Release E 512k free, D=256k,256k free Release D 1 MB

Buddy System Internal and External Fragmentation 129k example Good compromise to overcome disadvantages of fixed and variable partitioning. Used in Linux some for kernel memory