Chapter3 Memory Management Techniques

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: 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 is achieved.
Allocating Memory.
CS 311 – Lecture 21 Outline Memory management in UNIX
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
1 Friday, June 30, 2006 "Man's mind, once stretched by a new idea, never regains its original dimensions." - Oliver Wendell Holmes, Jr.
Memory Management Chapter 5.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store.
Chapter 8 Main Memory Bernard Chen Spring Objectives To provide a detailed description of various ways of organizing memory hardware To discuss.
Example of a Resource Allocation Graph CS1252-OPERATING SYSTEM UNIT III1.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 32 Paging Read Ch. 9.4.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
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.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation.
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.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
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.
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.
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.
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.
Memory Management Chapter 7.
Memory.
Chapter 9: Memory Management
Memory Management By: Piyush Agarwal ( ) Akashdeep ( )
Memory Management.
ITEC 202 Operating Systems
Chapter 2 Memory and process management
Memory management.
Memory Allocation The main memory must accommodate both:
UNIT–IV: Memory Management
Chapter 8: Main Memory.
Chapter 8 Main Memory.
Main Memory Management
Module IV Memory Organization.
Chapter 8: Main Memory.
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Chapter 8: Main Memory.
Operating System Concepts
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Main Memory Session -15.
CSS 430: Operating Systems - Main Memory
Multistep Processing of a User Program
Unit 6: Real Memory organization management
Memory Management.
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
Memory Management-I 1.
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 (1).
Chapter 8: Memory Management strategies
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Chapter 8: Main Memory.
Page Main Memory.
Presentation transcript:

Chapter3 Memory Management Techniques

What is meant by memory management and how to manage memory? Ready Queue Process need to be executed Memory management is how to organize active processes (processes currently in the ready queue) so that: Processes can be easily reached. Maximize memory space utilization.

Show how a loader stores an executable file into the memory assuming: File of Size =20 memory words (instructions and data). Using Contiguous allocation method. Repeat the problem three different times using: First fit. Best fit. Worst Fit. Executable file (Size =20 memory words) Memory Loader ?

Using First Fit Memory OS Process Process Process Process Process OS 1040 20 Base Limit Start address of process Legal range 999 1000 1010 Process 1040 Process 1060 Executable file (Size =20 memory words) 1070 Process 1100 1125 Process 1150 Loader 1200 Process 1250 1255

Using Best Fit Memory OS Process Process Process Process Process 1100 20 Base Limit Start address of process Legal range 1000 1010 Process 1040 Executable file (Size =20 memory words) 1070 Process 1100 Process 1120 1125 Process Loader 1150 1200 Process 1250 1255

Using Worst Fit Memory OS Process Process Process Process Process 1150 20 Base Limit Start address of process Legal range 1000 1010 Process 1040 Executable file (Size =20 memory words) 1070 Process 1100 1125 Process Loader 1150 Process 1170 1200 Process 1250 1255

How to manage memory in multi-programming environment? Memory Management In multi-programming environment Paging Swapping Contiguous allocation

Swapping: A process can be swapped out of memory to disk, and then brought back into memory for continued execution.

Multi-programming environment with “priority scheduling” Ex1: Multi-programming environment with “priority scheduling” Assume a system with 32 kb memory size. 5kb are used for OS, 10 kb for the low priority process. Hence, the available space is 17 kb. A higher priority process arrives and needs 20 kb. OS (5 kb) Low Priority process (10 kb) Available 17 Kb 27 Kb High Priority process (20 kb) 7 Kb Swap in the high priority process high priority process finishes execution Swap out the low priority process to disk Disk Swap in the low priority process again to resume execution High Priority 20 Kb

Contiguous Allocation What is meant by contiguous allocation, what are its different types? In contiguous allocation, each process is contained in a single contiguous section of memory.

Methods for Contiguous Allocation Simple Method General Method

Simple Method Divide memory into several fixed-sized partitions. Each partition contains one process. Degree of multiprogramming is bound by the number of partitions. When a partition is free, a process is selected from the input queue and is loaded into the free partition. When the process terminates, the partition becomes available for another process. its no longer used because it has various drawbacks like: Degree of multiprogramming is bounded by the number of partitions. Internal fragmentations.

As shown This method suffers from internal fragmentations. Assuming a memory of 30 KB divided into three partitions as following: Process 1 (7 KB) Input Queue (in the disk) 10 KB Internal Fragmentation Process 2 (9 KB) 4 KB 8 KB 9 KB 7 KB 10 KB Process 3 (8 KB) 10 KB As shown This method suffers from internal fragmentations. The degree of multiprogramming is bounded to 3 although it can be 4.

General Method Initially, all memory is available for user processes, and is considered as one large block of available memory. When a process arrives and needs memory, we search for a hole large enough for this process using. If we find one, we allocate only as much memory as is needed, keeping the rest available to satisfy future requests. First Fit Best Fit Worst Fit

X There are three different methods to find the suitable hole for a process?: First fit: allocate the first hole that is big enough (fastest method). Best fit: allocate the smallest hole that is big enough (produces the smallest leftover hole). Worst fit: allocate the largest hole (produces the largest leftover hole which may be more useful than the smaller leftover hole from a best-fit approach.

OS Process 4 (4 KB) Process 1 (7 KB) Input Queue (in the disk) Process 5 (9 KB) Process 2 (9 KB) 9 KB 4 KB 8 KB 9 KB 7 KB Process 3 (8 KB) As shown: The degree of multiprogramming changing according to the number of processes in the memory (in ready queue).

After a period of time External Fragmentations appear OS Process 4 Input Queue (in the disk) Process 2 External Fragmentations Process 3 4 KB 8 KB 9 KB 7 KB Process 9 Process 20 As shown: This method suffers from external Fragmentations.

Compaction OS OS Compaction: Process 2 Process 3 OS Process 4 Process 9 Process 20 OS Process 4 Input Queue (in the disk) Process 2 Process 3 4 KB 8 KB 9 KB 7 KB Process 9 A new hole to store a new process Process 20 Compaction: Is a movement of the memory contents to place all free memory in a one large block sufficient to store new process. It is a solution for the external fragmentation but it is expensive and is not always possible.

Paging Paging is a memory-management scheme that permits the physical-address space of a process to be noncontiguous. it is commonly used in most operating systems. Divide physical memory into fixed-sized blocks called frames. Divide Process into blocks of same size called pages. Use a page table which contains base address of each page in physical memory. X

Example A process P is divided into 4 pages. 1 2 3 Page number Page number Frame number Process P The process will be loaded into 4 frames. The page number is used as index to the page table. The page table contains the frame number for each page.

Paging Example Sol: Memory size=32 Byte =32 words. 32-byte memory, each memory word of size =1 byte (can store only one character), the size of page (and frame also)= 4-byte. Show how to store 4 pages process into memory using a page table. according to your page table, what are the physical addresses corresponding to the logical addresses 4 and 13. Sol: Memory size=32 Byte =32 words. Page size = Frame size = 4 bytes =4 words. Number of Frames = 32/4 = 8 Frames (addressed from 0  7)

Logical address Page 0 Contents Physical address Page 0 Page 1 Page 2 Page 3 4 Page process Frame 0 Frame 1 Frame 2 Frame 3 Frame 4 Frame 5 Frame 6 Frame 7

Advantages of paging: Problems in paging: No external fragmentation. Allow the process components to be noncontiguous. Problems in paging: A possibility of internal fragmentations that can not be used. Q: Explain when you have internal fragmentations when using the paging technique. Sol: when the contents of the last page of the process is less than the frame size, then the remaining part of the frame will be an internal fragmentations that can not be used.