MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.

Slides:



Advertisements
Similar presentations
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Advertisements

Part IV: Memory Management
Chapter 6: Memory Management
Memory Management Chapter 7.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
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.
OS Fall’02 Memory Management Operating Systems Fall 2002.
CS 104 Introduction to Computer Science and Graphics Problems
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.
Computer Organization and Architecture
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Chapter 3 Memory Management: Virtual Memory
Chapter 9: Memory Management Memory management is an OS activity which controls distribution of memory among processes. The part of the OS that manages.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Memory Management Chapter 7.
Operating Systems Chapter 8
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
Chapter 7 Memory Management
Chapter 10 Memory Management Part_1. 2 Overview Basic Concepts The major tasks of the memory manger are the allocation and deallocation of main memory.
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. 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.
Virtual Memory. Background Virtual memory is a technique that allows execution of processes that may not be completely in the physical memory. Virtual.
Operating Systems (CS 340 D) Princess Nora University Faculty of Computer & Information Systems Computer science Department.
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.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
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 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.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
2010INT Operating Systems, School of Information Technology, Griffith University – Gold Coast Copyright © William Stallings /2 Memory Management.
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.
Chapter 7 Memory Management
Memory Management Chapter 7.
Memory Management.
ITEC 202 Operating Systems
Chapter 2 Memory and process management
UNIT–IV: Memory Management
Chapter 8 Main Memory.
Main Memory Management
Module 9: Virtual Memory
Chapter 9: Virtual-Memory Management
Multistep Processing of a User Program
Memory Management.
Main Memory Background Swapping Contiguous Allocation Paging
Contents Memory types & memory hierarchy Virtual memory (VM)
Module 9: Virtual Memory
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Module IV Memory Organization.
Page Main Memory.
Presentation transcript:

MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala

Operating System A operating system is a set of master programs which is desired to control entire operations of computer. Operating System is a general purpose software which is involved in each and every activity of the computer. The various functions of operating system are Interface between user and hardware Peripheral Management Memory Management Process Management

Memory Memory refers to the physical devices used to store the data temporary or permanent. There are two types of memories that are 1. Primary Memory:- These are internal memory of computer. They are very fast. The two types of primary memory are RAM and ROM. 2. Secondary Memory:- These are physical devices to store program and data. They are slow to access with higher memory capacity. The various types of secondary memories are tape, magnetic disks and optical discs.

Principals of Memory Management The various aim and principals of memory management are To provide the memory space to enable many processes to be executed at same time. To protect the processes from each other. To provide satisfactory level as performance to users. To make addressing of memory space transparent for an programmer.

Address Binding Each program resides on a disk but it must be brought to memory for execution. The process has to be moved between disk and memory. Thus different memory address are used at different location. The process of changing the addresses during storage is called binding. The various types of binding are Compile Time Binding Load Time Binding Execution Time Binding

Physical and Logical Address 1. Physical Address:- The actual addresses that refer to actual physical location of the main memory are called physical addresses. 2. Logical Address:- The addresses generated by CPU are called Logical addresses. The logical and physical addresses are same at compile time and load time binding. But it differs at Execution time binding. The mapping of logical address to physical addresses is done by hardware device called Memory Management Unit.

Relocation The logical addresses are converted into physical addresses by the help of relocation register present in Memory Management Unit or by relocating linkers and loader. The ability to load and execute a given program to arbitrary place in memory is called relocation. The user program supplies logical address must be mapped to physical addresses before they are used. The types of Relocation are Static Relocation Dynamic Relocation

Relocation The types of Relocation are Static Relocation :- The Static Relocation is performed before or during the loading of program into memory. This is done by relocating linkers and relocating loaders. Dynamic Relocation :- The Dynamic relocation is performed during the execution of the program. This is done by the help of the hardware support called Memory management Unit (MMU).

Relocation Memory CPU + Logical Address Physical Address 346 14346 MMU 346 14346 MMU Memory Relocation Register 14000 CPU +

Partitioning The Operating System manages the main memory by dividing the memory into regions of fixed or variable size is called Partitioning. It manages the main memory efficiently. The two types of partitions are Static Partition:- The whole memory is divided into fixed sized frame is called static partition. Dynamic Partition:- The memory is divided into variable sized frame according to page size is called dynamic partition.

Static Partition Dynamic Partition Partitioning Example 0 0 10 10 15 15 20 30 33 38 40 40 47 50 50 Static Partition Dynamic Partition process space P1 10 P2 5 P3 18 P4 7 P1 P2 P3 P4 P1 P2 P3 P4

Fragmentation Fragmentation is a process in which storage space is used inefficiently, reducing capacity and often performance. Fragmentation leads to storage space being wasted, and the term also refers to the wasted space itself. The two types of fragmentation are 1. External fragmentation 2. Internal fragmentation This problem is overcome by using Disk defragmentation.

Contiguous Memory Allocation Each logical object is placed in physical memory at consecutive addresses is called contiguous memory allocation. Generally memory is partitioned and any process requesting memory is allocated a partition. On termination, process release memory partition to a free pool of memory. There are number of scheme which can be used for a system but we can rate efficiency of a particular memory management scheme like wasted memory, time complexity, memory access overheads.

Static Partitioned Memory Allocation The memory partition are created sometime before the execution of user programs these partitions remain fixed. This approach is known as Static Partitioned Memory Allocation. The number and size of partitions is fixed during system generation process by considering 1. Capacity of memory, 2. Degree of multiprogramming, 3. Size of program.

Dynamic Partitioned Memory Allocation The memory partition are created dynamically in response to process requests. This approach is known as Dynamic Partitioned Memory Allocation. The partition creation process goes on till the whole memory has been utilized. Whenever a process requests for memory partition, memory management of operating system creates a suitable partition to allocate to the process. It selects the greater or equal size to process, allocate the memory and keeps the record in PDT.

Algorithms First Fit:- OS searches the first partition large enough to store process. Next Fit:- The memory manager keep a pointer on the free list to store process. Best Fit:- Memory manager searches free list from beginning to end and selects the smallest possible portion to hold process. Worst Fit:- The memory manager scans the free list and allocate the largest memory block to create partition to store process.

Swapping The process of a suspended or preempted process in main memory with a new process is called swapping. When all memory partitions have been allocated and there is need to allocate a partition to a process, a suspended or preempted processes is taken out from the memory in order to bring new process. Swapping is used to implement the multi programming in the system which have less hardware support for memory management. Swapping is done by module called Swapper

Swapping Process P1 Process P2 Operating System User Space Swap out Swap in Operating System User Space Process P1 Process P2

Compaction The process of relocating all partitions into one end of memory and to combine holes into large free area is called compaction. When the memory becomes fragmented, solution is to relocate all partition into one end using compaction. All the effected processes are suspended and they are copied from one to another area of memory. It can be performed whenever possible or only when needed. System compacts memory when large free area is return or there is failure to allocate memory.

Paging Paging is a memory management scheme that permits the physical address space of a process to be non contiguous. In paging physical memory is divided into fixed sized partitions called frames. Virtual address space is also divided into blocks of same size called pages. A page map table is used for address translation. The virtual address of a process is divided into two parts that are Page number (p) Page offset (d)

Paging

Segmentation Segmentation is memory management scheme in which the address space of single process is divided into blocks that may be placed into non contiguous area of memory. Due to external fragmentation the waste memory increases which should be reduced in system by using the segmentation to utilize the memory in proper manner. Segment descriptor table is use to record the details of different segment belonging to different process area in memory. It is flexible and easy to use.

Segmentation The translation from virtual to physical address in main memory is done as follows. The segment number of virtual address is used to access the segment descriptor table. It is checked that whether the offset of segment is within bound of segment. The base address of segment is obtained from SDT. The offset of the virtual address is added to physical base address to get actual physical address.

Segmentation

Virtual Memory The secondary memory that is used to keep the portions of address spaces of currently executing process is called virtual memory. The portions are shifted to and fro between main memory and virtual memory. Virtual memory is a technique that allows the execution of processes that may not be completely in memory. By this method CPU can execute the program as large as physical memory.

Virtual Memory The various issue that are specific to virtual memory concept are Allocation Policy:- decides how much real memory to be allocated to each process. Fetch Policy :- decides when and which items are to be brought to main memory. Replacement Policy:- decides which item should replaced with new memory. Placement policy:-decides about placement of an incoming item in physical memory.

Demand Paging A demand paging system is similar to a paging system with swapping. Processes reside on secondary memory. When we want to execute a process, we swap it into memory. A swapper swaps the page into memory only when it needed. It avoids reading into memory pages that will not be used anyway thus decreasing the swap time and amount of physical memory needed. The hardware support for demand paging is page table and secondary memory which is same as in paging and swapping.

Page Replacement To reduce the page faults occurrence, we used the technique of page replacement. In this if no frame is free, the OS finds the one that is not in used and make it free. Then this freed frame is used to hold the page which is faulted. The routine for page replacement are Find the location of desired page on disk. Find a free frame a. if there is a free frame, use it. b. if there is no free frame, use a page

Page Replacement replacement algorithm to select the victim frame and write victim page to disk change the page and frame table accordingly. 3. Read the page to free frame, change the page and frame tables. 4 . Restart the user process. The algorithm used for page replacement are a. FIFO Page Replacement, b. LRU page Replacement, c. Optimal Page Replacement

First In First Out FIFO replacement algorithm is the simplest replacement algorithm. In this page which is the oldest one is replaced with the new page. It use the page queue in which the page at the head is replaced with the page inserted at the tail. It is implement by using the FIFO queue. There is Belady anomaly problem with FIFO replacement algorithm. The number of page faults are increases with increase in number of frames in main memory.

First In First Out Example:- Consider the main memory consists of 3 frames for FIFO Page Replacement algorithm and input pattern of memory pages. 7 0 1 2 0 3 0 4 2 3 0 7 7 7 1 2 1 2 1 2 3 1 2 3 4 3 4 2 4 2 3 2 3

Optimal Page Replacement The Optimal Page Replacement algorithm replace the page that will not be used for longest period of time. The page which might not be used for longer time is replaced with the new page. This replacement algorithm has lowest page fault rate. This algorithm is difficult to implement as it requires future knowledge of the reference string. It overcome the belady’s anomaly.

Optimal Page Replacement Example:- Consider the main memory consists of 3 frames for Optimal Page Replacement algorithm and input pattern of memory pages. 7 0 1 2 0 3 0 4 2 3 0 7 7 7 1 2 1 2 1 2 3 2 3 2 4 3 2 4 3 2 4 3 2 3

Least Recently Used The least recently used algorithm will replace the page that has not been used for longest period of time. LRU replacement. LRU chooses that page which has not been used for the longest period of time. This algorithm is looking backward in time, rather than forward that is used in Optimal page replacement. The two implementation for LRU are Counters and Stack.

Least Recently Used Example:- Consider the main memory consists of 3 frames for LRU Page Replacement algorithm and input pattern of memory pages 7 0 1 2 0 3 0 4 2 3 0 7 7 7 1 2 1 2 1 2 3 2 3 4 3 4 2 4 3 2 3 2

Summary Memory refers to the physical devices used to store the data temporary or permanent. The process of changing the addresses during storage is called binding. The binding is of three types are Compile Time, Load Time, Execution Time Binding. The actual addresses that refer to actual physical location of main memory are called physical addresses. The addresses generated by CPU are called Logical addresses.

Summary The OS manages the main memory by dividing the memory into regions of fixed or variable size is called Partitioning. The secondary memory that is used to keep the portions of address spaces of currently executing process is called virtual memory. A demand paging system is similar to a paging system with swapping The algorithm used for page replacement are FIFO Page Replacement, LRU page Replacement, Optimal Page Replacement.

Thanks