Full blocks of memory used in the physical memory.
<aside> ⚠️ Not used in modern architecture anymore.
</aside>

Memory is split into pages that are mapped to a frame, or a physical address.
A contiguous block memory.
Pages and frames are made of offset and number.
Page offset - Number of bits to represent the page size in virtual memory.
Page number - Number of bits to represent the page address in virtual memory.
Frame offset - Number of bits to represent the frame size in physical memory.
Frame number - Number of bits to represent the frame address in physical memory.
<aside> 💡 The page and frame offset will always be the same in translation.
</aside>

Pages do not necessarily need to be contiguous on the physical memory. They have the ability to be stored as an individual page with different neighbouring pages.

<aside> ✅ Pages can help solve problems from segmented memory such as:
</aside>
Swap memory is a type of virtual memory that acts as an extension of a computer's physical memory.
When the physical RAM is fully utilized, the OS moves some of the data from RAM to a designated area on the hard drive or SSD, called the swap space. This process frees up space in the RAM for new data.
Swap partition is a reserved space in the disk for swaps. It is hardcoded in the disk.
Swap file holds the same purpose as swap partitions, but can be resized and relocated without modifying the disk partitions.
Page tables map page table entries (PTE) to physical addresses.
PTE - An entry for a virtual address to physical address translation.
Multi level page table.
<aside> ⚠️ When a translated virtual address does not have a physical address, the memory management unit (MMU) will return DISK and call a page fault. Page faults are very slow, and the OS switches to DMA when it occurs.
</aside>
Direct Memory Access (DMA) is the process of transferring data without the processor’s involvement.
However, pages itself is generally slow due to the expensive steps it takes to translate one page.
TLB is a hardware component that caches virtual to physical address translations, speeding up the process.

TLBs are very small but fast, storing around 4000 entries.
How it works
Modern architectures usually have two TLBs, one for instructions, and one for data.
The process of loading pages that are only accessed by a process. Demand paging uses a lazy swapper that brings only necessary pages into the memory.

Lazy swapper diagram.
<aside> 💡 This is the most common type of paging, used in almost every modern architecture.
</aside>

The stack is used for managing function calls and local variables.
Local variables, function parameters, and return addresses are stored here.
Automatically managed by the operating system.
Data structure: LIFO
The heap is used for dynamic memory allocation.
Memory allocation is not automatically managed by the OS, and is larger than the stack. It is the programmer’s responsibility to allocate and deallocate memory.
This segment holds global and static variables that are declared but not initialized by the programmer.
Example:
static int x;
Without an explicit value, it will be stored in the BSS segment.
This segments holds global and static variables explicitly initialized by the programmer
Example
static int x = 1;
Memory is allocated for these variables at the start of the program and persists until the program terminates.
The text segment contains executable code of the program. It is where instructions for the CPU is stored.
Typically read-only to prevent accidental modification of instructions during execution.