codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🖥️

Operating Systems

25 chapters

1Intro to OS & Kernel Architecture2Process Concept & Lifecycle3System Calls & Interrupts4Process Management & PCB5Inter-Process Communication (IPC)6CPU Scheduling (FCFS, SJF, RR)7Threads (User vs Kernel Level)8Process Synchronization9Critical Section Problem10Producer-Consumer Problem11Dining Philosophers Problem12Deadlock Conditions & Prevention13Banker's Algorithm (Avoidance)14Memory Management & Paging15Memory Allocation (First Fit, Best Fit)16Paging and Segmentation17Translation Lookaside Buffer (TLB)18Virtual Memory & Demand Paging19Page Replacement Algorithms20Thrashing21File Systems & Directory Structure22File Allocation Methods23Disk Scheduling Algorithms24I/O Systems & DMA25OS Protection & Security
SubjectsOperating Systems

Memory Management & Paging

Updated 2026-04-28
3 min read

Memory Management & Paging

Main memory is central to the operation of a modern computer system. Main memory is a large array of bytes, each with its own address. The CPU reads instructions from main memory and reads/writes data to it. The Operating System's memory manager is responsible for allocating space to processes and ensuring they do not interfere with one another.

1. Contiguous Memory Allocation

Early operating systems allocated memory contiguously. This means that a process was given a single, continuous block of memory.

  • Fixed Partitioning: The memory is divided into several fixed-size partitions. A process is allocated into a partition that is large enough to hold it.
  • Variable Partitioning: The OS keeps a table indicating which parts of memory are available and which are occupied. When a process arrives, the OS searches for a hole large enough to accommodate it.

The Problem: Fragmentation

  • External Fragmentation: Occurs when there is enough total memory space to satisfy a request, but the available spaces are not contiguous.
  • Internal Fragmentation: Occurs when memory allocated to a process is slightly larger than the requested memory.

2. Paging

Paging is a memory-management scheme that eliminates the need for contiguous allocation of physical memory. This scheme permits the physical address space of a process to be noncontiguous.

How Paging Works

  1. Physical Memory (Frames): Physical memory is broken into fixed-sized blocks called frames.
  2. Logical Memory (Pages): Logical memory is broken into blocks of the same size called pages.
  3. Page Table: When a process is to be executed, its pages are loaded into any available memory frames from their source. The OS maintains a Page Table for each process, which translates logical page numbers into physical frame numbers.

Advantage of Paging: Paging avoids external fragmentation completely and the need for compaction. Any free frame can be allocated to a process that needs it.

3. Virtual Memory

Virtual memory is a technique that allows the execution of processes that are not completely in memory. One major advantage of this scheme is that programs can be larger than physical memory.

Virtual memory is commonly implemented by Demand Paging. In demand paging, a page is not loaded into main memory until it is needed. When a process tries to access a page that was not brought into memory, a Page Fault occurs. The OS then traps the interrupt, loads the required page from disk into a free frame in memory, updates the page table, and restarts the instruction.



PreviousBanker's Algorithm (Avoidance)NextMemory Allocation (First Fit, Best Fit)

Recommended Gear

Banker's Algorithm (Avoidance)Memory Allocation (First Fit, Best Fit)