Chapter 6: Memory Management

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.
Memory Management Chapter 7.
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable supply of ready processes to.
Allocating Memory.
Chapter 7 Memory Management
Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2009, Prentice.
CS 311 – Lecture 21 Outline Memory management in UNIX
OS Fall’02 Memory Management Operating Systems Fall 2002.
CSCI2413 Lecture 5 Operating Systems Memory Management 1 phones off (please)
Chapter 3.1 : Memory Management
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
CS 104 Introduction to Computer Science and Graphics Problems
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 Chapter 5.
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.
Tutorial 6 Memory Management
Tutorial 7 Memory Management presented by: Antonio Maiorano Paul Di Marco.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Memory Management Chapter 7.
Dynamic Partition Allocation Allocate memory depending on requirements Partitions adjust depending on memory size Requires relocatable code –Works best.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
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.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Chapter 4 Memory Management.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Subject: Operating System.
1 Memory Management Requirements of memory management system to provide the memory space to enable several processes to execute concurrently to provide.
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.
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.
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 OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
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 Chapter 7.
Chapter 7 Memory Management
Memory Management Chapter 7.
Memory Management.
ITEC 202 Operating Systems
Chapter 2 Memory and process management
Memory Allocation The main memory must accommodate both:
Partitioned Memory Allocation
Main Memory Management
Module IV Memory Organization.
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.
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
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.
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:

Chapter 6: Memory Management

Basics Requirements that drive memory designs Purpose of memory manager is to administer the use the use of the primary memory. Primary memory and CPU are the fundamental resources used by every process. REQUIREMENT ON PRIMARY MEMORY The primary memory access time must be as small as possible. This need influences both software and hardware design The primary memory must be as large as possible. Using virtual memory, software and hardware can make the memory appear to be larger than it actually is The primary memory must be cost-effective. The cost cannot be more than a small percentage of the total cost of the computer.

3 Functions of Memory Manager The purpose of the memory manager is to allocate primary memory space to processes to map the process address space into the allocated portion of the primary memory to minimize access times using a cost- effective amount of primary memory

Memory allocation In an environment that supports dynamic memory allocation, the memory manager must keep a record of the usage of each allocatable block of memory. Memory allocation is the process assigning blocks of memory on request. There are 3 memory allocation: i. First Fit, Worst Fit, Best Fit ii. Buddy System Iii. Suballocators

3.2 Variable Partitioning There are three algorithms for searching the list of free (free list) blocks for a specific amount of memory. First Fit Best Fit Worst Fit When recycling free blocks, there is a choice as to where to add the blocks to the free list. Free list kept: Memory allocation(address) Increasing size(best fit) Decreasing size (worst fit) Increasing time

first fit First Fit : Allocate the first free block that is large enough for the new process. This is a fast algorithm. Another strategy is first fit, which simply scans the free list until a large enough hole is found. Despite the name, first-fit is generally better than best-fit because it leads to less fragmentation. Variation of first fit known ad next fit, continues each search for a suitable block

Initial memory mapping first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping

first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB arrives

first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P4 of 3KB loaded here by FIRST FIT

first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P5 of 15KB arrives

first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P5 15 KB P5 of 15 KB loaded here by FIRST FIT

Best fit Best Fit : Allocate the smallest block among those that are large enough for the new process. In this method, the OS has to search the entire list, or it can keep it sorted and stop when it hits an entry which has a size larger than the size of new process. This algorithm produces the smallest left over block. Problem: Requires more time for searching all the list or sorting it. It leads to the creation of lots of little holes that are not big enough to satisfy any requests. This situation is called fragmentation, and is a problem for all memory- management strategies, although it is particularly bad for best-fit.

Initial memory mapping best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB arrives

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB loaded here by BEST FIT

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P5 of 15KB arrives

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB P5 15 KB P5 of 15 KB loaded here by BEST FIT

worst fit Worst Fit : Allocate the largest block among those that are large enough for the new process. The memory manager places process in the largest block of unallocated memory available. The ideas is that this placement will create the largest hole after the allocations, thus increasing the possibility that, compared to best fit, another process can use the hole created as a result of external fragmentation.

Initial memory mapping worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB arrives

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB P4 of 3KB Loaded here by WORST FIT

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB No place to load P5 of 15K

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB No place to load P5 of 15K Compaction is needed !!

compaction Compaction is a method to overcome the external fragmentation problem. All free blocks are brought together as one large block of free space. Compaction requires dynamic relocation. Certainly, compaction has a cost and selection of an optimal compaction strategy is difficult. One method for compaction is swapping out those processes that are to be moved within the memory, and swapping them into different memory locations

Memory mapping before compaction OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB Memory mapping before compaction

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Secondary storage Swap out P2

compaction OS P1 12 KB P2 20 KB P4 3 KB Swap in P3 6 KB P2 Secondary storage

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Secondary storage Swap out P4

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Secondary Swap in storage Swap in P4 with a different starting address

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Secondary storage Swap out P3

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap in P3 Secondary storage

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB <FREE> 27 KB Memory mapping after compaction Now P5 of 15KB can be loaded here

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB P5 12 KB <FREE> 12 KB P5 of 15KB is loaded

relocation Static relocation: A process may be loaded into memory, each time possibly having a different starting address Necessary for variable partitioning Dynamic relocation: In addition to static relocation, the starting address of the process may change while it is already loaded in memory Necessary for compaction

Buddy System The allocator will only allocates blocks of certain sizes and has many free lists, one for each permitted size. The permitted sizes are usually either powers of 2, such that any block except the smallest can be divided into two smaller blocks of permitted sizes. Advantages: coalescence is cheap because buddy of any free block can be calculates from its address. See eg 6.2.2

Suballocators A suballocator obtains large blocks of memory from the system memory manager and allocates the memory to the application in smaller pieces. Function suballocator: To avoid general inefficiency in the system memory manager. To take advantage of special knowledge of the application’s memory requirements To provide memory management services that the system memory manager does not supply.

Memory Manager Strategies 1. Swapping To optimize system performance by removing a process from primary memory. RAM has limited capacity. Virtual memory as additional of RAM. The area hard disk used for virtual memory is called swap file. When more RAM space is needed, the OS swaps out from RAM and moved to virtual memory. The technique of swapping items between memory and storage called paging.

2. Virtual Memory Dynamic Relocation Allow a process to use the CPU when only part of its address space is loaded in the primary memory. Dynamic Relocation Refers to address transformations being done during execution of a program.

Tutorial Define memory allocation Quest of Nov2011 Define memory allocation Give three way to allocate memory in our system. Explain 3 functions that must be performed by memory manager in order to execute program and data. List three basic requirements of designing primary memory. List 2 strategies to manage memory Define what is best fit, worst fit and first fit. Quest of Nov2011 Quest of Nov2011 Quest of Nov2010