What is swap memory ?.

What is Memory Swapping?

A program might include multiple overlays that occupy the same memory at different times. Overlays are not a method of paging RAM to disk but merely of minimizing the program’s RAM use. Subsequent architectures used memory segmentation, and individual program segments became the units exchanged between disk and RAM. A segment was the program’s entire code segment or data segment, or sometimes other large data structures. These segments had to be contiguous when in RAM, requiring additional computation and movement to remedy fragmentation. The invention of the page table let the processor operate on arbitrary pages anywhere in RAM as a seemingly contiguous logical address space. These pages became the units exchanged between disk and RAM.

What is swap memory

Page faults

When a process tries to reference a page not currently present in RAM, the processor treats this invalid memory reference as a page fault and transfers control from the program to the operating system. the operating system must:

  • Determine the program to the operating system. The operating system must:
  • Obtain an empty page frame in RAM to use as a container from the data.
  • Load the requested data into the available page frame.
  • Update the page table to refer to the new page frame.
  • Return control to the program, transparently retrying the instruction that caused the page fault.

When all page frames are in use the operating system must select a page frame to reuse for the page the program now needs. If the evicted page frame was dynamically allocated by a program to hold data, or if a program modified it since it was read into RAM, it must be written out to disk before being freed. If a program later references the evicted page, another page fault occurs and the page must be read back into RAM.

How to check memory utilization

The method the operating system uses to select the page frame to reuse, which is its page replacement algorithm or an algorithm based on the program’s working set. To further increase responsiveness, paging systems may predict which page will be needed soon, preemptively loading them into RAM before a program references them.

 Leave your message if anything is missed and we appreciate your comments.

mukesh.thakur87: