3.0 : Resource Management Part 1 : Memory Management.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
Chapter 2: Memory Management, Early Systems
Chapter 2: Memory Management, Early Systems
Memory Management, Early Systems
Understanding Operating Systems Fifth Edition
Allocating Memory.
CS 311 – Lecture 21 Outline Memory management in UNIX
Memory Management Design & Implementation Segmentation Chapter 4.
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
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 5: Memory Management Dhamdhere: Operating Systems— A Concept-Based Approach Slide No: 1 Copyright ©2005 Memory Management Chapter 5.
Computer Organization and Architecture
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 2 Memory Management: Early Systems (all ancient history)
Understanding Operating Systems Fifth Edition
Chapter 3 Memory Management: Virtual Memory
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-7 Memory Management (1) Department of Computer Science and Software.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Memory Management Chapter 7.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
Memory Management. Process must be loaded into memory before being executed. Memory needs to be allocated to ensure a reasonable supply of ready processes.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
Chapter 2 Memory Management: Early Systems Understanding Operating Systems, Fourth Edition.
Chapter 2 Memory Management: Early Systems Understanding Operating Systems, Fourth Edition.
Page 1 2P13 Week 5. Page 2 Page 3 Page 4 Page 5.
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.
CE Operating Systems Lecture 14 Memory management.
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.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
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.
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.
Understanding Operating Systems Fifth Edition Chapter 3 Memory Management: Virtual Memory.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
1 Memory Management n In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes.
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.
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 Damian Gordon.
Memory Management.
Chapter 2 Memory and process management
Memory Allocation The main memory must accommodate both:
Chapter 9 – Real Memory Organization and Management
Main Memory Management
Chapter 8: Main Memory.
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.
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 3: Main Memory.
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.
COMP755 Advanced Operating Systems
Page Main Memory.
Presentation transcript:

3.0 : Resource Management Part 1 : Memory Management

Learning Outcomes Understand the Memory Management Types of memory allocate scheme Single – User Configuration Fixed – partition memory management Dynamic memory management Paging Segmentation Virtual Memory Dynamic Address Translation

Primary Activities Perform in Memory management Keep track of which part of memory are currently being used and by whom. Decide which process to load when memory becomes available Allocate and deal locate memory space as needed

Features of Static and Dynamic Memory Allocation Kind of AllocationKey features Static Allocation Allocation before start of execution of program Size should be known before start of execution, else over allocation and wastage of memory will result No allocation during program execution Dynamic Allocation Allocation during execution of program Allocation exactly equal requirement, no wastage of memory Allocation overhead during program execution

Types of Memory Allocation Scheme a.Single – User Configuration b.Fixed- Partition c.Dynamic Partition d.Paging/ Paged Memory Allocation e.Segmentation

Memory Allocation Scheme: Single – User Configuration Is early memory management schema – seldom use by today OS. This is fundamentals concept that helped memory management evolve Single – User Configuration work like this ; – Each program to be processed was loaded entirely and allocated as must contiguous space in memory as it needed. – If the program too large and didn’t fit the available memory space, it couldn’t be executed – It demonstrates limiting factor of all computer.

Memory Allocation Scheme: Single – User Configuration Each user given access all available main memory for each job and job processed sequentially, one after the other For allocate memory OS use this algorithm;

Algorithm to load a job in a Single – User Configuration 1.Store first memory location of program into base register (for memory protection) 2.Set program counter (it keeps track of memory space used by the program) equal to address of first memory location 3.Read first instruction of program 4.Increment program counter by number of bytes instruction 5.Has last instruction been reached? 1.If yes, then stop loading 2.If no, then continue with step 6 6.Is program counter greater than memory size? 1.If yes, stop loading 2.If no, then continue step 7 7.Load instruction in memory 8.Read next instruction of program 9.Go to step 4

Memory Allocation Scheme: Single – User Configuration Notice amount of work done by operating system using these schema is minimal. The code perform the function is straightforward and logic is quite simple Only two hardware item is needed: – a register (to store the base address ) – a accumulator (to keep track the size of program as it’s being read into memory) Once program is entirely loaded into memory, it remains there until execution is complete, either through normal termination or by intervention of the OS

Major problem in Single – User Configuration Scheme The scheme doesn’t support multiprogramming It can only handle one job at a time Commercially in the late 1940s and early 1950s

Memory Allocation Scheme: Fixed Partition First attempt to allow multiprogramming – create fixed partition scheme within the main memory (one partition of each job) Also known as static partition This is because the size of partition was designated when the system was powered on. Each partition could only be reconfigured when the computer system was shut down, reconfigured, restart. Once system in operation the partition sized remained static

Algorithm to load a job in a Fixed Partition 1.Determine job requested memory size 2.If job_size > size of largest partition Then reject the job 1.Print appropriate message to operator 2.Go to step 1 to handle next job in line Else Continue with step 3 3.Set counter to 1 4.Do while counter <= number of partitions in memory If job_size > memory _partition_size (counter) Then counter = counter +1 Else If memory_partition_status(counter) = free Then load job into memory_partition(counter) change memory_partition_status(counter) to “busy” go to step 1 Else counter = counter +1 End do No partition available at this time, put job in waiting queue, get next job Go to step 1

Example of Fixed Partition 2560K Operating System 0 400K 2160K Job Queue Process P1600K P21000K P3300K P4700K P5500K size

Example of Fixed Partition

Advantages and Disadvantages of Fixed Partition AdvantagesDisadvantages More flexible scheme compare to single – user scheme because allow several program to be in memory at the same time. Internal Fragmentation occur Internal fragmentation is allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used. However, it still requires that the entire program be stored contiguously and in memory from the beginning to the end of it’s execution

Memory Allocation Scheme : Dynamic Partition Available memory is still kept in contiguous block But jobs are given only as much memory as they request when they are loaded for processing. Improvement over fixed partition because memory isn’t wasted within the partition. Dynamic partition scheme fully utilize memory when the first job loaded. Will use concept first –come first serve priority. External Fragmentation occur– total memory space exists to satisfy a request, but it is not contiguous

Memory Allocation Scheme: Paging Is dividing incoming job into pages of equal size Normally OS choose a page size same as memory block size and same size as section of the disk in which the job is stored. – Section of the disk called sector/ block – Section of the main memory are called pages frame The scheme work quite efficiently when the pages, sector and page frame are all the same size.

Memory Allocation Scheme: Paging Before execute a program/job, Memory Manager prepares it by : – Determining the number of pages in the program – Locating enough empty pages frames in main memory – Loading all of the program’s pages into pages frames When program/job is initially prepared for loading, pages are in logical sequence (the 1 st page contain the first instructions of the program and last page has the last instructions) Program instruction can be thought as lines of code or bytes.

Memory Allocation Scheme: Paging The loading process is different from the previous schemes because the pages do not load in contiguous memory blocks. Each page can be stored in any available page frame. Anywhere in main memory

Example 1 Memory Allocation Scheme: Paging

Example 2 Memory Allocation Scheme: Paging

Memory Allocation Scheme: Paging AdvantagesDisadvantages Is storing program in noncontiguous location is that main memory. Main memory is used more efficiently because an empty page frame can be used by any page of any job Because job pages / program can be located anywhere in main memory, Memory Manager needs mechanism to keep track of them(job pages). Eliminate compaction scheme. Which is used for reloadable partition. This is because of no external fragmentation between pages frames External Fragmentation a situation happened in dynamic allocation scheme. Creates unusable fragment of free memory between blocks of busy, or allocated, memory. Enlarging the size and complexity of the operating system software. Which increase overhead Internal fragmentation is still a problem, although only in the last page of each job

Memory Allocation Scheme : Segmentation Concept : based on the common practice by programmers of structuring their program in modules Segmentation scheme : each job is divided into several segment of different sizes. One for each module that contains pieces that perform related function Main memory is no longer divided into page frames because the size of each segment is different (some are large some are small) When a program is compiled the segment are set up according to the program’s structural modules.

Memory Allocation Scheme : Segmentation A program is a collection of segments. A segment is a logical unit such as: – Main program,subroutine – Procedure – Function – Method – Object – Local variable, global variable, – Stack, array,symbol table

Memory Allocation Scheme : Segmentation Each segment is numbered and a Segment Map Table(SMT) is generated for each job. SMT contains the segment numbers, their lengths, access right, status and when each is loaded into memory and it’s location Memory Manager need to keep track of the segments in memory.

Memory Allocation Scheme : Segmentation Each segment is numbered and a Segment Map Table(SMT) is generated for each job. SMT contains the segment numbers, their lengths, access right, status and when each is loaded into memory and it’s location Memory Manager need to keep track of the segments in memory.

Memory Allocation Scheme : Segmentation Memory-management scheme that supports user view of memory. User’s View of a Program

Memory Allocation Scheme : Segmentation user spacephysical memory space

Memory Allocation Scheme : Segmentation Before execute the program/job Memory Manager prepare it by : – The job table list every job in process (one for whole system) – The Segment Map Table lists details about each segment (one for each job) – The Memory Map Table monitor the allocation of main memory (one for the whole system) The program’s instructions within each segment are ordered sequentially. The segment don’t need to be stored contiguously in memory The content of the segments themselves are contiguous in this scheme.

Example Memory Allocation Scheme : Segmentation To access specific location within a segment we can perform an operation similar to the one used paging scheme. Differences is segment instead of pages. The addressing scheme requires the segment number and the displacement within segment Because the segment are of different sizes, the displacement must be verified to ensure it isn’t outside the segment’s range.

Memory Allocation Scheme : Segmentation SMT – map two dimensional physical address; each table has limit : specifies the length(size) of the segment base : contain the starting physical address where the segments reside in memory (memory address)

Comparison of memory allocation schemes SchemeProblem SolvedProblem CreatedChanges in Software Single-user contiguous -Job size limited to physical memory size -CPU often idle None Fixed PartitionIdle CPU time-Internal fragmentation occur -Job size limited to partition size -Add Processor Scheduler -Add protection handler Dynamic PartitionsInternal fragmentationExternal FragmentationNone PagingNeed for compaction scheme -Memory needed for tables -Job size limited to physical memory size -Internal fragmentation returns Need algorithm to handle Page Map Tables Segmentation-Internal fragmentation -Sharing of segments Difficulty managing variable-length segments in secondary storage - External fragmentation Two-dimensional addressing scheme

Virtual Memory Virtual memory it is a illusion of a memory which is different from a real memory (RAM) existing in a computer system. This memory maybe much larger than the real memory. The basis of VM implementation is noncontiguous memory allocation

Cont.. Noncontiguous allocation permit parts of a program to be loaded into two or more non- adjacent areas of memory execution This technique is reduce the problem of memory fragmentation since free area memory can be reused even the size is small than free memory. VM implementation is an arrangement which enable program to execute even when its entire code and data are not present in the memory

Cont.. The idea is to load required portion of code /data in memory at any time By this arrangement allow execution of program which size program exceed the size of memory. This strategy increases the number of program which can accommodated in memory. All modern general-purpose computer operating systems use virtual memory techniques for ordinary applications, such as word processors, spreadsheets, multimedia players, accounting, etc

Dynamic Address Translation Dynamic address translation (DAT) is the process of translating a virtual address during a storage reference into the corresponding real address.