UNIT - III

Memory Management

Logical Vs. Physical Address Space

Logical Address Space: Addresses generated by the CPU during program execution.

Physical Address Space: Actual location in the main memory.

Swapping:
In computing, swapping involves the dynamic movement of a part of a program between the computer's main memory (RAM) and the storage disk.

  • When active programs demand more memory than available in RAM,
  • Less frequently used data is temporarily transferred to the disk.
This process optimizes memory usage, allowing smooth operation of multiple programs even when physical memory is limited.

Process Overview: When a program needs more memory than is currently available in RAM, the operating system identifies less critical data in the RAM. The identified data is then swapped out to the storage disk, making space for the more actively used program or data in RAM.

Optimizing Memory Usage: Swapping optimizes memory usage by ensuring that the most relevant and actively used data resides in the faster RAM for quick access. Less critical or infrequently accessed data is stored on the comparatively slower storage disk.

Benefits: Swapping enables the smooth operation of multiple programs concurrently, even when physical memory is limited. It prevents programs from crashing due to insufficient memory by efficiently managing available resources.

Performance Considerations: While beneficial for preventing memory-related issues, swapping can introduce performance overhead. Reading/writing to the storage disk is slower than accessing data directly from RAM.

Memory Management Requirement

Memory Management Requirement: Efficient allocation, deallocation, and protection of memory.

Dynamic Loading and Dynamic Linking

Dynamic Loading: Loading a module into memory when needed.

Dynamic Linking: Linking postponed until execution time.

Memory Allocation Methods»

Single Partition Allocation

This memory allocation method involves dedicating the entire system's memory to a single process.

  • Straightforward Approach:
  • It is a simple and direct method where a process exclusively occupies the entire available memory space without sharing it with other processes.

  • Resource Utilization:
  • While it ensures that the allocated process has access to the full memory, it may lead to inefficient utilization of resources when multiple processes are competing for memory.

Multiple Partitions

This memory allocation method involves dividing the system's memory into fixed or variable partitions to accommodate multiple processes simultaneously.

  • Partition Types:
  • Memory can be divided into fixed-size or variable-size partitions, each capable of hosting an individual process.

  • Concurrent Execution:
  • Enables multiple processes to execute concurrently by assigning each process to a specific partition in memory.

  • Optimizing Resource Usage:
  • Allows for better resource utilization as multiple processes can run simultaneously, sharing the available memory partitions.

Compaction:

Compaction is a memory management technique that involves rearranging the memory contents to minimize fragmentation and optimize memory utilization.

Key Points:

  • Fragmentation Reduction: Compaction aims to reduce fragmentation, both internal and external, in the memory space. Internal fragmentation occurs when allocated memory is not fully utilized, while external fragmentation arises when free memory is scattered throughout the address space.
  • Memory Reorganization: During compaction, the operating system shifts allocated blocks of memory to consolidate free space. This reorganization helps create larger contiguous blocks of free memory, making it easier to allocate larger chunks of memory to programs.
  • Improves Allocation Efficiency: By minimizing fragmentation and creating larger contiguous memory blocks, compaction improves the efficiency of memory allocation. It reduces the likelihood of allocation failures due to insufficient contiguous free memory.
  • Dynamic Process: Compaction is typically performed dynamically by the operating system when needed. It can be triggered when a program requests a significant amount of contiguous memory, and the available free space is fragmented.
  • Trade-offs: While compaction improves memory utilization, it comes with the trade-off of increased overhead during the reorganization process. The time and computational resources required for compaction need to be balanced against the benefits of improved memory efficiency.

Paging:

Paging is a memory management scheme that allows the operating system to use fixed-size blocks of physical memory, known as pages, to manage and organize the virtual memory used by programs.

Key Points:

  • Page Size: The physical memory is divided into fixed-size blocks called pages. Similarly, the virtual memory used by programs is divided into pages of the same size.
  • Address Translation: Paging involves translating virtual addresses used by programs into corresponding physical addresses. This translation is done through a data structure called the page table.
  • Page Table: The page table is a data structure that maps virtual pages to physical pages. It helps in determining the actual location of data in physical memory when it is accessed by a program.
  • Advantages of Paging:
    • Eliminates External Fragmentation: Since pages are of fixed size, paging eliminates external fragmentation. Free memory can be allocated in page-sized blocks, reducing wasted space.
    • Allows for Efficient Memory Management: Paging facilitates efficient memory management by providing a structured way to map virtual to physical memory, allowing for easy allocation and deallocation of memory pages.
  • Disadvantages and Challenges:
    • Internal Fragmentation: Paging may suffer from internal fragmentation, where the last page allocated may not be fully utilized, leading to wasted space within a page.
    • Overhead: Maintaining the page table and performing address translation can introduce overhead. Efficient algorithms are required to mitigate this overhead.

As of Now, This website only supports screens which are below 1024px, Please bear with it✨🙂

Help and support

Did this doc help you?

Help us make these docs great!

All these documentations are open source. See something that's wrong or unclear? Submit a pull request.

Learn how to contribute

Still need help? Ask the GitHub community

Contact support @Chetan Raut