
Memory Management Strategies in Operating Systems
Explore the fundamentals of memory management strategies in operating systems, including memory allocation, address binding, logical vs. physical address space, and dynamic relocation techniques using a relocation register. Learn about the role of Memory Management Unit (MMU) and the multistep processing of user programs in efficient memory usage and address mapping.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Memory Management Strategies: Part I (Memory Allocation) By: Dr. Ankur Aggarwal Assistant Professor, DAV Centenary College, Faridabad Subject: Operating system- 402 Class: B.SC 4thSemester
Memory-Management Unit (MMU) Memory consists of a large array of words or bytes, each with its own address. The CPU fetches instructions from memory according to the value of the program counter. These instructions may cause additional loading from and storing to specific memory addresses. Hardware device that maps virtual to physical address In MMU, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory The user program deals with logical addresses; it never sees the real physical addresses"
Address Binding Addresses in the source program are generally symbolic . A compiler binds these symbolic addresses to relocatable addresses. The linkage editor or loader then binds the relocatable addresses to absolute addresses. Each binding is a mapping from one address space to another.
Address binding of instructions and data to memory addresses can happen at three different stages as below: Compile time: If memory location known a priori, absolute code can be generated; must recompile code if starting location Changes Load time: Must generate relocatable code if memory location is not known at compile time can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g., base and limit registers). Execution time: Binding delayed until run time if the process
Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate physical address space is central to proper memory management Logical address generated by the CPU; also referred to as virtual address Physical address address seen by the memory unit Logical and physical addresses are the same in compile-time and load-time address-binding schemes. Logical (virtual) and physical addresses differ in execution-time address-binding scheme
The base register is called a relocation Register. The value in the relocation register is added to every address generated by a user process at the time the address is sent to memory. In the above figure, if the base is at 14000, then an attempt by the user to address location 0 is dynamically relocated to location 14000; an access to location 346 is mapped to location 14346.
Dynamic Loading With dynamic loading, a routine is not loaded until it is called. All routines are kept on disk in a relocatable load format. The main program is loaded into memory and is executed. When a routine needs to call another routine, the calling routine first checks to see whether the other routine has been loaded. If it has not, the relocatable linking loader is called to load the desired routine into memory.
Advantages of Dynamic Loading An unused routine is never loaded. Dynamic loading does not require special support from the operating system.
Swapping A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution Backing store is a fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images Roll out, roll in is a swapping variant used for priority-based scheduling algorithms. Lower-priority process is swapped out so higher-priority process can be loaded and executed Major part of swap time is transfer time. Total transfer time is directly proportional to the amount of memory swapped
Contiguous Allocation Main memory is usually divided into two partitions: i. Resident operating system, usually held in low memory with interrupt vector ii. User processes then held in high memory Each (Single-partition) allocation i. Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data" ii. Relocation register contains value of smallest physical address; limit register contains range of logical addresses each logical address must be less than the limit register
Multiple-partition allocation: Hole block of available memory; holes of various size are scattered throughout memory When a process arrives, it is allocated memory from a hole large enough to accommodate it Operating system maintains information about: a) allocated partitions b) free partitions (hole)
Dynamic Storage-Allocation First-fit: Allocate the first hole that is big enough Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole.
Fragmentation External Fragmentation : Gaps between allocated contiguous memory - total memory space exists to satisfy a request, but it is not contiguous External fragmentation exists when there is enough total memory space to satisfy a request but the available spaces are not contiguous; storage is fragmented into a large number of small holes.
Internal Fragmentation : allocated memory may be slightly larger than requested memory; this size In Internal fragmentation, the memory allocated to a process may be slightly larger than the requested memory. The difference between these two numbers is internal fragmentation unused memory that is internal to a partition.