What Is Memory Management
What Is Memory Management
In a multiprogramming computer, the Operating System resides in a part of memory and the rest is used by multiple processes. The task of subdividing the
memory among different processes is called Memory Management. Memory management is a method in the operating system to manage operations between
main memory and disk during process execution. The main aim of memory management is to achieve efficient utilization of memory.
Paging is a memory management scheme used by operating systems to efficiently utilize physical memory. Here are the key aspects of paging:
Principle of Operation:
Paging divides the virtual memory of a process into fixed-size blocks called pages. Similarly, physical memory is divided into frames of the
same size.
The virtual address space of a process is divided into pages, and the corresponding physical address space is divided into frames.
When a process references a memory address, the virtual address is translated to a physical address using a page table, which maintains the
mapping between virtual pages and physical frames.
The page table is stored in the memory and is accessed to perform the address translation.
Page Allocation:
When a process is created or requires more memory, pages are allocated to it. The allocation can be done in two ways: demand paging or
pre-paging.
Demand paging allocates pages to a process only when they are needed. Initially, only a small portion of the program is loaded into
memory, and additional pages are loaded as they are accessed.
Pre-paging, on the other hand, loads additional pages into memory even before they are accessed, based on certain algorithms or
heuristics.
Paging relies on hardware support provided by the CPU and memory management unit (MMU).
The MMU performs the translation of virtual addresses to physical addresses using the page table.
The CPU includes special registers, such as the page table base register and the page table length register, which hold the location and size
of the page table, respectively.
The CPU also generates page faults if a required page is not present in memory, triggering the operating system to bring it in from disk.
Paging facilitates memory protection by assigning access permissions to each page. The page table entry includes protection bits that
control read, write, and execute permissions for a given page.
Paging also enables memory sharing among multiple processes. Pages can be marked as read-only and shared among multiple processes,
reducing memory consumption and facilitating inter-process communication.
Disadvantages of Paging:
Internal Fragmentation: Paging can lead to internal fragmentation, where memory pages or frames are not fully utilized, resulting in wasted
memory space. This can happen if a page is not fully occupied by data or if a page is larger than necessary.
Overhead: Paging introduces additional overhead in terms of memory consumed by the page table and the overhead of address translation
performed by the MMU.
Thrashing: Thrashing occurs when the system spends a significant amount of time swapping pages between disk and memory due to
excessive page faults. It can severely degrade system performance.
It's important to note that while paging offers advantages such as efficient memory utilization and protection, its implementation and impact can vary
depending on the specific operating system and hardware architecture