UGC NET/JRF June 2023 |Operating System | Memory Management-Contiguous and Non-Contiguous| Partition Allocation, Swapping, Fragmentation, Relocation, Buddy System, Compaction



Memory Management


Memory is a large array of words or bytes, each having its unique address. CPU fetches instructions from memory according to the value of the program counter. The instructions undergo an instruction execution cycle. To increase both CPU utilization & speed of its response to users, computers must keep several processes in memory. Specifically, the memory management modules are concerned  with the following four functions:
1.  Keeping track of whether each location is allocated or unallocated, to which process & how much.
 2.  Deciding to whom should the memory is allocated, how much, when & where. If memory is to be shared by more than one process concurrently, it must be determined which process request should be satisfied. 
3.  Once it is decided to allocate memory, the specific locations must be selected & allocated. Memory status information is updated.
 4.  Handling the deallocation/reclamation of memory. After the process of holding memory is finished, memory locations held by it are declared free by changing the status information.

Memory Management Systems

There are varieties of memory management systems. They are:

1.  Contiguous, real memory management system such as:

 •  Single, contiguous memory management system
•  Fixed partitioned memory management system
•  Variable Partitioned memory management  system

2. Non-Contiguous,  real  memory management  system

 •  Paged memory management system
•  Segmented memory management  system •  Combined memory management  system

 3. Non-Contiguous,  virtual  memory management system

 •  Virtual memory management system

These systems can be divided into two major parts
(i) Contiguous & (ii) Non Contiguous

 Contiguous Memory  Management:

 Each program occupies a single contiguous block of storage locations in this approach.
INR2,499
 

Non-Contiguous Memory  Management: 

In these, a program is divided into several blocks or segments that may be placed throughout main storage in pieces or chunks not necessarily adjacent to one another. It is the function of the OS to manage these different chunks in such a way that they appear to be contiguous to the user. Various issues to be considered in various memory management schemes are relocation, address translation, protection, sharing, & evaluation.

 Relocation& address translation:

 The process of associating program instructions & data to physical memory addresses is called address binding or relocation. So binding is mapping from one address to another.
 It is of two types:

Static Binding: It is taking place before  execution; it may be

(i) Compile time: where the compiler or  assembler  translates symbolic addresses to absolute addresses &
 (ii) Load time: where the compiler translates symbolic addresses to relative addresses. The loader translates these to absolute addresses.

 Dynamic Binding: In it, new locations are determined during execution. The program retains its relative addresses.  The absolute addresses are generated by hardware.


 Memory  Protection & Sharing:

  Protection is used to avoid interference between programs existing in memory. Sharing is the opposite of protection.

 Evaluation:  Evaluation of these schemes is  done on various parameters such as:

Wasted memory:  It is the amount of physical memory, which remains unused & thus wasted.
 Access time - is the time to access the physical memory by the OS.
Time complexity - is related to overheads of the allocation or deallocation methods.


SINGLE CONTIGUOUS MEMORY MANAGEMENT 

Physical memory is divided into two contiguous areas. One of them is permanently allocated to the resident portion of the OS. Mostly, the OS resides in low memory. The remaining memory is allocated to transient or user processes, which are loaded & executed one at a time, in response to user commands. This process is run to completion & then the next process is brought in memory.

 FIXED PARTITIONED MEMORY MANAGEMENT SYSTEM 

In this scheme, memory is divided into a number of contiguous regions called partitions, which could be of different sizes. But once decided, they could not be changed. Partitions are fixed at the time of system generation. System generation is a process of setting the OS to specific requirements.

  Strategies of Partition Allocation are:

 First-fit: This strategy allocates the first available space that is big enough to accommodate the process. The search may start at the beginning of a set of holes or where the previous first fit ended. Searching stops as soon as it finds a free hole that is large enough. 
Best fit: This strategy allocates the smallest hole that is big enough to accommodate the process. The entire list ordered by size is searched & matching the smallest leftover hole is chosen.
 Worst fit: This strategy allocates the largest hole. The entire list is searched. It chooses the largest leftover hole. 


These strategies may be compared on the basis of execution speed & memory utilization must be made.  The first fit tends to execute faster but the best fit may achieve higher utilization of memory by creating the smallest possible gap resulting from the difference in size between the process & its allocated partition.
 Both first-fit & best fit are better than worst-fit in terms of time & storage utilization, but first-fit is faster. 
Request for partitions may be due to 
(1) creation of new processes or 
(2) reactivations of swapped-out processes. The memory manager attempts to satisfy these requests from the pool of free partitions. Common obstacles faced by it are: 
1. No free partition is large enough to accommodate the incoming process.
 2. All partitions are allocated. 
3. Some partitions are free, but none of them is large enough to accommodate the incoming process.


The OS holds the processes waiting to be loaded in the memory in a queue. The two methods of maintaining this queue are 
(i) Multiple Queues 
(ii) Single Queues. 
Multiple Queues: In this method, there are as many queues as the number of partitions. A separate queue for each partition is maintained in which processes are added as they arrive. When a process wants to occupy memory, it is added to a proper queue depending upon the size of the process. The benefit of this method is that a small process is not loaded in a large partition so as to avoid memory wastage. This leads to a longer queue for small partitions.

 Single Queue: In this method, there is only one queue for all ready processes. The order of processes in the queue depends on the scheduling algorithm. In this case, the first fit allocation strategy is more efficient & fast. 

  Fragmentation- Some amount of memory is wasted both in single & multiple partition allocation techniques.  Fragmentation refers to the unused memory that the memory management system cannot allocate. It is of two types: 

 External 
 Internal.

 External Fragmentation is a waste of memory between partitions caused by scattered non-contiguous free space. It occurs when the total available memory space is enough to satisfy the request for a process to be allocated, but it is not continuous. The selection of the first fit & best fit can affect the amount of fragmentation. It is severe in variable-size partitioning schemes. Compaction is a technique that is used to overcome this.  


Internal fragmentation is a waste of memory within a partition caused by the difference between the size of the partition & the process allocated. It refers to the amount of memory, which is not being used & is allocated along with a process request i.e. available memory internal to the partition. It is severe in fixed partitioning schemes. 

INR3999



Swapping  - A process of Removing suspended or preempted processes from memory & their subsequent bringing back is called swapping. 

  • The basic idea of swapping is to treat the main memory as a ‘pre-emptive’ resource. 
  • Lifting the program from the memory & placing it on the disk is called ‘Swapping out’. 
  • To bring the program again from the disk into the main memory is called ‘Swapping in’. 
  • Normally, a blocked process is swapped out so as to create available space for a ready process. This results in improving CPU utilization. Swapping has traditionally been used to implement multiprogramming in systems with restrictive memory capacity.

 Swapping may also be helpful for improving processor utilization in partitioned memory environments by increasing the ratio of ready-to-resident processes. 

Swapping is usually employed in memory-management systems with contiguous allocation, such as fixed & variable partitioned memory & segmentation. 

Somewhat modified swapping forms may also be present in virtual memory systems based on segmentation or paging. 

Swapping brings flexibility even to systems with fixed partitions. 


 Relocation 

 The ability to load & execute a given program into an arbitrary place in memory. Since different load addresses may be assigned during different executions of a single relocatable program, a distinction is often made between virtual addresses (or logical addresses) & the physical addresses where the program & its data are stored in memory during a given execution. 
In reality, the program may be loaded at different memory locations, which are called physical addresses. 

The problem of relocation & address translation is to find a way to map virtual addresses onto physical addresses. Depending on when & how the mapping from the virtual address space to the physical address space takes place in a given relocation scheme, 
there are two basic types of relocation:
 (i) Static relocation  
(ii) Dynamic relocation. 

Static Relocation is performed before or during the loading of the program into memory, by a relocating linker/ loader. Constants, physical I/O port addresses, & offsets relative to the program counter are examples of values that are not location-sensitive & that do not need to be adjusted for relocation. Other forms of addresses of operands may depend on the location of a program in memory so must be adjusted accordingly when the program is being loaded or moved to a different area of memory. 


Dynamic Relocation 

 Mapping from the virtual address space to the physical address space is performed at run-time. Process images in systems with dynamic relocation are also prepared to assume the starting location to be a virtual address 0, & they are loaded in memory without any relocation adjustments. When the related process is being executed, all of its memory references are relocated during instruction execution before physical memory is actually accessed.


INR36,490 GoPro HERO9 Black — Waterproof Action Camera with Touch Screen 5K Ultra HD Video 20MP Photos 1080p Live Streaming Stabilization, Dual Screen, HyperSmooth 3.0 and Time Warp 3.0 


 Evaluation -
 Wasted memory: In fixed partitions, a lot of memory is wasted due to both kinds of fragmentation. 
 Access Time: Access time is not very high due to the assistance of special hardware. The translation from virtual address to physical address is done by the hardware itself, thus enabling rapid access. 
 Time complexity is very low because allocation/ deallocation routines are simple as the partitions are fixed. 

  Variable Partitions Memory Allocation 
The number of partitions & their sizes are variable as they  are not defined at the time of system generation.
 Starting with the initial state of the system, partitions are created dynamically to fit the needs of each requesting process. When a process departs, the memory manager returns the vacated 
space to the pool of free memory areas from which partition allocations are 
made. The process allocated exactly as much memory as required.

Buddy System: This is a method of allocation-deallocation that speeds up the merging of adjacent holes. This method facilitates the merging of free space by allocating free areas with an affinity to recombine. It treats the entire space available as a single block of 2k, Requests for free areas are rounded up to the next integer power of base 2.
 When a free block of size 2k is requested, the memory allocator attempts to satisfy it by allocating a free block from the list of free blocks of size 2k. 
If none is available, the block of the next larger size, 2k+1, is split in two halves (buddies) to satisfy the request. An important property of this allocation scheme is that the base address of the other buddy can be determined given the base address & size of one buddy . 

Compaction


  • It is one solution to the problem of external fragmentation. The goal here is to shuffle memory contents & place all free memory together in one block. 


INR52,990 

  • Compaction is possible only if relocation is dynamic. This technique shifts the necessary process images to bring the free chunks of memory to adjacent positions to coalesce. Coalescing of adjacent free areas is a method often used to reduce fragmentation and the amount of wasted memory. However, such remedies tend to defer the impact of, rather than to prevent, the problem. 
  • The primary reason for fragmentation is that, due to different lifetimes of resident objects, the pattern of returns of free areas is generally different from the order of allocations. 
  •  When memory becomes seriously fragmented, the only way out may be to relocate some or all partitions into one end of memory & thus combine the holes into one large free area. Since affected processes must be suspended & actually copied from one area of memory into another


Evaluation of Variable Partition of Memory-


 Wasted memory: This memory management scheme wastes less memory than fixed partitions because there is no internal fragmentation as the partition size can be of any length. By using compaction, external fragmentation can also be eliminated. 
 Access Time: Access time is same as of fixed partitions as the same scheme of address translation using base register is used. 
 Time Complexity: Time complexity is higher in variable partitions due to various data structures & algorithms used.


HP Pavilion x360, Intel 11th Gen Core i5 16GB/512GB SSD 14-inch Touchscreen 2-in-1 Laptop, FHD IPS Micro-Edge Anti-Glare Display/Backlit KB/B&O Audio/FP Reader/Win 11 Ready/1.41 Kg, 14-dy0053TU INR84600

HP Pavilion x360 11th Gen Intel Core i7-16GB RAM/512GB SSD 14-inch(35.6 cm) FHD, IPS, Convertible Laptop (B&O/Win 11/Backlit keyboard/FPR/ Alexa-Built in/MS Office/Natural Silver/1.52 Kg) -14-dy1013TUINR67900

Dell New 2022 Inspiron 3511---Intel Core i3-11th Gen || 8GB Ram || 1TB HDD+256GB SSD || Windows 11 Home+Office 2021 || Backlight Keyboard || FHD Display || Black Color || Sandisk 32GB Dual Pendrive ||INR 48,999