Virtual Memory
Virtual memory is a memory management scheme where secondary storage can be used as if it were a part of
the main memory. The main adavantage of this scheme is that programs can be larger than physical memory.
Demand Paging
Demand paging is a method of virtual memory management. In a system that uses demand paging, the
operating system copies a disk page into physical memory only if an attempt is made to access it and
that page is not already in memory.
Page Fault
Page fault is a type of exception raised by computer hardware when a running program accesses a
memory page that is not currently mapped by the Memory Management Unit (MMU) into the virtual address
space of a process.
Copy on Write
Copy on Write (COW) is a resource management technique. One of its main use is in the implementation
of the fork system call in which it shares the virtual memory of the operating system.
Page Replacement Algorithm
Page replacement algorithm is used to decide which page to replace. The page is needed to be replaced
because the actual physical memory is smaller than the virtual memory. Therefore page faults might
happen.
Page Buffering Algorithm
The operating system maintains a pool of free frames. When a page fault occurs, a page isselected for
replacement and written into the pool of free frames. The faulty page is swapped outof disk and the
page table is modified.
Allocation of Frames
Frame allocation algorithms are used if we have multiple processes and it helps decide how many
frames to allocate to each process. The two algorithms commonly used to allocate frames to a process
are: Equal allocation and Proportional allocation.
Thrashing
If page fault and swapping happening very frequently at higher rate, then operating system has to
spend more time to swap these pages.
This state is called thrashing. Because of this, CPU utilization is going to be reduced.
Memory Compression
Memory compression is the alternative of paging. Rather than paging out modified frames to swap
space, we compress several frames into a single frame, enabling the system to reduce memory usage
without resorting to swapping pages. Most memory compression processes are automatic, and only become
active when the memory begins to fill up.
Allocating Kernel Memory
When a process running in user mode requests additional memory, pages are allocated from the list of free page frames maintained by the kernel. Two strategies for managing free memory that is assigned to kernel processes: Buddy system and Slab allocation.