Loading...

OPERATING SYSTEMS ADMINISTRATION  

>

LEARNING OUTCOME 3

Memory Management

Memory management is the process of allocating and deallocating memory to various programs and processes in a computer system. It ensures efficient utilization of memory resources, preventing conflicts and maximizing system performance.

Importance of Memory Management

Memory Management Techniques

Memory Swapping

Memory swapping, also known as paging or swapping, is a memory management technique used by operating systems to temporarily move inactive processes or parts of processes from main memory (RAM) to secondary storage (like a hard disk) to free up physical memory for active processes.

Benefits of Memory Swapping

Process of Memory Swapping

  1. Process Selection: The operating system selects a process to be swapped out, typically based on factors like memory usage, priority, and recent activity.
  2. Page Table Update: The operating system updates the page table of the selected process to indicate that the pages have been swapped out to secondary storage.
  3. Page Transfer: The pages of the selected process are transferred from main memory to secondary storage.
  4. Frame Allocation: The freed memory frames are allocated to other processes that require additional memory.
  5. Page Fault: When a process attempts to access a page that has been swapped out, a page fault occurs.
  6. Page Retrieval: The operating system retrieves the required page from secondary storage and loads it into a free memory frame.
  7. Page Table Update: The page table of the process is updated to reflect the new location of the page in main memory.
  8. Process Resumption: The process can now continue its execution, accessing the required page from main memory.

Memory Allocation

Memory allocation is the process of assigning memory space to programs and data structures during program execution. It ensures that processes have the necessary memory to operate correctly and efficiently.

Memory Allocation Techniques

Memory Allocation Strategies

Memory Deallocation

Memory deallocation is the process of releasing memory that is no longer needed. It is crucial to avoid memory leaks, which occur when memory is allocated but not deallocated, leading to wasted resources.

Memory Management Considerations

Memory Paging

Memory paging is a memory management technique where physical memory is divided into fixed-size blocks called frames, and logical memory is divided into equal-sized blocks called pages. When a process needs to access a particular memory location, the operating system translates the logical address into a physical address. If the required page is not present in physical memory (a page fault occurs), the operating system loads the page from secondary storage (like a hard disk) into a free frame.

Memory Fragmentation

Memory fragmentation occurs when memory is allocated and deallocated in a way that leaves small, unusable blocks of memory scattered throughout the memory space. This can significantly impact system performance.

Memory Segmentation

Memory segmentation is a variable-sized segments, each containing a specific logical unit of a program. These segments can be of different sizes and can be loaded into non-contiguous physical memory locations.

Swapping vs. Paging

Feature Swapping Paging
Basic Unit Entire process Fixed-size pages
Memory Allocation Contiguous blocks of memory Non-contiguous pages
Page Table Not required Required for address translation
Performance Overhead Higher overhead due to larger data transfers Lower overhead due to smaller data transfers
Memory Utilization Less efficient, as entire processes are swapped More efficient, as only the necessary pages are swapped
Fragmentation External fragmentation Internal fragmentation
Complexity Simpler to implement More complex to implement

Segmentation vs. Paging

Feature Segmentation Paging
Memory Division Variable-sized segments Fixed-size pages
Address Translation Segment table and page table Page table only
Memory Allocation Contiguous or non-contiguous Non-contiguous
Fragmentation External fragmentation Internal fragmentation
Flexibility More flexible for program structure Less flexible for program structure
Performance Can be less efficient due to larger page table More efficient due to smaller page table

Fragmentation and System Performance

Fragmentation can significantly impact system performance in the following ways:

Virtual Memory

Virtual memory is a memory management technique that gives an application the illusion of having more memory than is physically available. It achieves this by storing parts of a program in secondary storage (like a hard disk) and swapping them into physical memory as needed.

blackgift00@gmail.com

Demand Paging

Demand paging is a memory management technique that loads pages into physical memory only when they are needed. This approach improves system performance by reducing the amount of physical memory required for each process.

Page Swapping

Page swapping is the process of moving pages between physical memory and secondary storage. When a page fault occurs (i.e., a page is accessed that is not currently in physical memory), the operating system selects a page to be swapped out and loads the required page into the freed frame.

Thrashing

Thrashing occurs when the system spends more time swapping pages between physical memory and secondary storage than executing processes. This can significantly degrade system performance. Thrashing can occur due to excessive process swapping, insufficient physical memory, or poor page replacement algorithms.

To avoid thrashing, the operating system can use various techniques, such as:

End of Outcome Quiz

1 of 20

    Quiz Score

    Percentage: 0%

    Answered Questions: 0

    Correct Answers: 0

    Faults: