Memory Management in Operating Systems: Paging, Swapping & Beyond

Virtual memory

Virtual memory is a memory management technique that gives the illusion of a large, continuous memory space to programs, even if the physical memory (RAM) is limited. It allows the operating system to use disk space (e.g. a swap file or page file) to extend RAM, enabling multitasking and isolation between processes.

Physical memory

Physical memory refers to the actual hardware (RAM) installed in a computer. It's where data and programs are stored temporarily while they are being used or executed.

Pages and Frames

In operating system memory management, pages and frames are fundamental concepts related to paging, a memory management scheme that eliminates the need for contiguous allocation of physical memory. Pages and Frames are different aspects of memory.

Comparison of Pages and Frames

FeaturePagesFrames
DefinitionFixed-size blocks of a logical (virtual) address spaceFixed-size blocks of physical memory (RAM)
Belong toProcess address spacePhysical memory
SizeSame as frame size (e.g., 4KB, 8KB) to ensure 1-to-1 mappingSame as page size
PurposeDivide the virtual memory of a process into manageable unitsHold the actual data from pages loaded into physical memory
Managed byMemory management unit (MMU) and OSMemory management unit (MMU) and OS
MappingPages are mapped to frames using page tablesFrames store the actual data of the pages mapped to them
LocationExist in virtual memory (on disk or RAM)Reside in physical memory (RAM)
SwappingPages can be swapped in and out of disk (e.g., to/from swap space)Frames are occupied by pages when they are loaded into RAM
ExampleA process has 10 pages in its virtual address spaceThe OS has 1000 frames available in RAM, each of 4KB

Comparison of MMU and Paging Tables

AspectMemory Management Unit (MMU)Paging Tables (Page Tables)
Definition Hardware component that handles memory address translation and protection. Data structure used by OS to store mappings of virtual addresses to physical addresses.
Role Performs address translation (virtual → physical) at runtime using page tables. Stores the actual mappings and metadata for each page.
Location Part of the CPU (hardware). Stored in memory (RAM), managed by the OS.
Function Translates virtual addresses to physical addresses using page table entries. Keeps track of virtual pages, frame numbers, valid/invalid bits, etc.
Speed Very fast; works in nanoseconds. Slower access; must be read by MMU during address translation (may be cached in TLB).
Dependency Depends on page tables for translation. Used by the MMU to perform translation.
Managed by Hardware (CPU manufacturers). Operating System (software).

Note

MMU = The brain that performs the translation.
Page Table = The dictionary that contains the translations.

Virtual memory = Simulated memory using disk + RAM.
Physical memory = Real, hardware-based RAM.

Swapping

  • Swapping is a memory management technique where entire processes are temporarily moved between main memory (RAM) and secondary storage (disk).
  • Free up RAM when it's full, by moving inactive processes to disk (called "swap space"), and bringing them back when needed.
  • Whole process is swapped in or out.

Segmentation

  • Segmentation divides a process's memory into logical segments, such as code, data, stack, etc.
  • Allows logical organization, protection, and sharing of memory.
  • Each segment is of variable size, and has its own base and limit.

Comparision of Swapping and Segmentation

FeatureSwappingSegmentation
DefinitionMoving entire processes between RAM and diskDividing a process into variable-sized segments
PurposeManage memory when RAM is fullAllow logical division of process memory
Unit of TransferEntire processIndividual segments (e.g., code, data, stack)
Memory DivisionNot divided logically — whole process is movedDivided based on logical units of a program
SizeProcess size can vary Segment sizes Vary based on program structure
AddressingUses single linear address space per processEach segment has its own base and limit
Use CaseUsed in memory overcommitment (swap in/out)Used for easier protection and sharing of memory
OverheadHigh (due to entire process movement)Moderate (due to managing multiple segments)

Note
Swapping = Moving entire processes in/out of memory.
Segmentation = Dividing process memory into logical parts.

Memory Management OS


A Beginner's Guide to File System in an Operating Systems

File Systems

A file system is a method to  store, organise, retrieve and manage data on storage devices (Hard disks, SSD, USB) by Operating system. There are many different file systems available. Key functions of file systems are: structure data into files and folders, tracks where data is physically stored on the disks, manage permissions and user access to files, supports creating, reading, writing, deleting and modifying files. These functions can be varied  file system to file system. One files system may not support with other file system. Diffrent operating systems uses different file systems.

Some of the widely used file systems are given below

  1. FAT (File Alloction Table)
    • FAT is the file systems introduced with Microsoft Disk Operating System (MS OS).
    • FAT uses a File Allocation Table (FAT) to keep track of files in the storage devices.
    • FAT and the root directory reside at a fixed location of the volume so that the system's boot files can be correctly located.
    • To protect a volume, two copies of the FAT are kept.
    • There are many variants such as Variants: FAT12, FAT16, FAT32
    • The advantages of FATare simple, widely compatible
    • The dis advantages of FAT are Limited size (4GB for FAT 32), It is not very secure
  2. exFAT (Extended File Allocation Table)
    • exFAT is used at USB drives, SD cards (cross-platform)
    • Advantages are Supports large files, compatible with Windows & macOS
    • Disadvantages are No journaling, less robust for system drives
  3. NTFS
    • (New Technology File System) is a proprietary file system developed by Microsoft. This is improvement of FAT. Windows (default)
    • This improvement includes The capability to recover from some disk-related errors automatically, which FAT cannot.
    • Support with Unicode encoding system
    • Improved support for larger hard disks.
    • Better security as permissions, journaling and encryptions are used to restrict access to specific files to approved users.
    • Disadvantages Limited support on non-windows systems
  4. ext (Extended File System)
    • (Extended File System): Commonly used in Linux distributions, with versions like ext4 offering journaling and improved performance.
    • There are many variant available ext2, ext3, ext4 in Linux
    • Advantages are ext4 supports journaling, large files, and volumes
    • Disadvantages are Limited compatibility with windows/macOs
  5. HFS+ and APFS:
    • Used by macOS, with APFS designed for solid-state drives, providing features like snapshots and encryption.
    • Older macOs used HFS+ file systems and APFS is used by modern macOS
    • Advatages of APFS are better performance, encryption and snapshots
    • Disadvantages not natively writable on non-Apple systems

Partitioning of a Disk

Partitioning is the process of dividing a physical storage device into separate independent sections.These independent section is called partitions. This partitioning is used for hard disk or SSD. Each partition can have its own file system, operating system, or usage purpose.

Why Partition a Disk

There are many advantages of patiting a disk. Some of them are given below

  • Organize Data – Keep system files separate from personal data.
  • Dual Boot – Install multiple operating systems (e.g., Windows + Linux).
  • Improve Performance – Manage storage more efficiently.
  • Backup & Recovery – Isolate system and recovery partitions.
  • Security – Limit access between partitions.

Partitioning Schemes

  • MBR (Master Boot Record): Older system, supports up to 2 TB and 4 primary partitions.
  • GPT (GUID Partition Table): Modern standard, supports larger disks and up to 128 partitions. Required for UEFI systems.

Types of Partitions

There are several types of Partitions are available

  • Primary Partition: Bootable partition that can host an OS (max 4 primary partitions per disk in MBR).
  • Extended Partition: A special type that holds multiple logical partitions (used when you need more than 4 partitions in MBR).
  • Logical Partition: A sub-part of an extended partition. Useful for organizing data.
  • EFI/System Partition: Required for booting in UEFI systems (in GPT partitioning).

Disk Formatting

Disk formatting is the process of preparing a storage device (like a hard drive or SSD) to store data.

There are two main types of disk formatting is available. They are Low-Level Formatting and High-Level Formatting.

Low-level formatting

Low-level formatting is the process of physically preparing the disk by creating sectors and tracks on the surface of the disk. Low-level formatting is done at the factory for modern drives. It defines how data will be physically stored on the disk. It is Rarely done by users today. It Lays down the magnetic markers for sectors/tracks.

High-Level Formatting

High-level formatting is the process of setting up a file system on the disk. Different Operating system can setup different file systems example windows can setup NTFS or FAT32 same time Linux can setup ext4. Operating system can store and manage files after the High-Level Formatting is done. Performed by the user (e.g., using tools like Windows Disk Management or mkfs in Linux or format in DOS). Tasks are done by High-Level formatting: Initializes the file system. Creates boot sector, file allocation table, root directory, etc. High-Level Formatting Can be quick format which just sets up file system structures, or full format which scans for bad sectors too.

Ex : Using DOS command; if we use to full formating c: drive   format c:   quick format c: drive  format C: /q  formating c: drive with DOS intalled format c:/s



Feature Low-Level FormattingHigh-Level Formatting
Level PhysicalLogical (file system)
Performed By Manufacturer (mostly)User or OS
Purpose Create sectors/tracks Create file system structureFrequency Rarely done by users Commonly done

The Different between Word Processing and Desktop Publishing

The Different between Word Processing and Desktop Publishing (DTP)

Word processing is creating, editing, formatting and printing text based documents using computer software. This software is called Word processing software. Examples for some of the word processing software are Micro soft word, Open office writer, Apple Pages, Google docs and Word perfect etc.

In other hand Desk top publishing is used to create high quality, visually rich printed or digital documents using software. This software is called desk top publishing software. Example for some of the desk top publishing software is Adobe InDesign, QuarkXPress, Scribus (Open source) and PageMaker.

DescriptionWord ProcessingDesk top publishing
Use Text-heavy documents For professional-looking, visually complex layouts
Software Microsoft Word, Google Docs, Open Office Writer, Apple Pages Adobe InDesign, QuarkXPress, Scribus (Open source), PageMaker
Best For Letters, Reports, Resumes Magazines, Brochures, Newsletters

Word Processing Vs DTP
Desk Top Publishing (DTP)

Disk Fragmentation and Defragmentation

Disk Fragmentation

  • Fragmentation is the unintentional division of Disk into many small free areas that cannot be used effectively due to scattered storage of file fragments.
  • It Occurs when files are stored in non-contiguous sectors on a disk. File operations are dynamic nature, where files grow and shrink, and blocks of data become available after deletions.
  • Fragmented files require head to move more for read or write operations, It increases access times and reduceds performance, mainly in hard disks

Disk fragmentation

Defragmentation

  • Defragmentation is a process that locates and eliminates file fragments by rearranging them.
  • The defragmentation tool analyzes the disk, identifies fragmented files, and moves them so that each file occupies a single contiguous block of space. It also consolidates free space to minimize fragmentation in the future.
  • Defragment a disk periodically is advisable, if it is heavily used.
  • Modern operating systems often automatically handle fragmentation using inbuilt tool.
    Example:
    Windows: The "Defragment and Optimize Drives"
    Linux: While Linux filesystems are generally more resistant to fragmentation, tools like e4defrag can be used for ext4 filesystems.
  • Solid-state drives (SSDs) do not require defragmentation. Its architecture allows for equal access times regardless of data location. Defragmenting an Solid-state drives(SSD) can reduce its lifespan due to unnecessary write cycles.

Benefits of Defragmentation

  • Improved Performance:
    By reducing the time it takes for the disk to access files, defragmentation can lead to faster boot times, quicker file access, and overall improved system responsiveness.

  • Extended Drive Life:
    Although the effect is more pronounced on Hard Disks, better performance can lead to less wear and tear over time.


Limitations of Defragmentation

  • Time-Consuming:
    Depending on the size of the disk and the level of fragmentation, defragmentation can take a significant amount of time. 

  • Temporary Impact:
    After defragmentation, further file operations may lead to fragmentation again, necessitating ongoing maintenance.

Defragmentation



IPv4 Address Classes with Ranges ICT

IPV4

Internet Protocol version 4 is the fourth version of the Internet Protocol. It is used to identify devices on a network and route traffic across the internet. It uses a 32-bit address format, allowing for about 4.3 billion unique IP addresses. An IPv4 address is typically written in four octets, separated by periods. Examples are  192.168.1.1, 10.1.1.1 etc.. IPv4 is widely used for internet communication.

IPV4 Subnet

IPv4 IP address Classes

There are five classes in IPv4 : A, B, C, D and E.

Each class has a specific range of IP addresses (Each Ranges have its own number of devices and number of  networks).

Class A, B, and C are used by the majority of devices on the Internet.

Class D and class E are for special uses.

IP addresses are categorized into private and public ranges

Public IP Address Range:

Public IP addresses are used on the internet and can be routed globally.

Private IP Address Ranges

These are reserved for use in private networks and are not routable over the public internet.


Class A (Supports 16 million hosts per network)

  • IP Range: 1.0.0.0 to 127.255.255.255
  • Subnet Mask: 255.0.0.0 (or /8)
  • Default Network Size: 8 bits for the network portion, 24 bits for the host portion
  • Usage: Primarily used for large networks.
  • Private Range: 10.0.0.0 to 10.255.255.255
  • Hosts per Network: 16,777,214

Class B (Supports 65,534 hosts per network)

  • IP Range: 128.0.0.0 to 191.255.255.255
  • Subnet Mask: 255.255.0.0 (or /16)
  • Default Network Size: 16 bits for the network portion, 16 bits for the host portion
  • Usage: Medium to large networks.
  • Private Range: 172.16.0.0 to 172.31.255.255
  • Hosts per Network:65,534

Class C (Supports 254 hosts per network)

  • IP Range: 192.0.0.0 to 223.255.255.255
  • Subnet Mask: 255.255.255.0 (or /24)
  • Default Network Size: 24 bits for the network portion, 8 bits for the host portion
  • Usage: Typically used for small networks, such as home and small office networks.
  • Private Range: 192.168.0.0 to 192.168.255.255
  • Hosts per Network:254

Class D (Multicast Addresses)

  • IP Range: 224.0.0.0 to 239.255.255.255
  • Usage: Used for multicast communications (group communication, like streaming, or broadcast applications).
  • Default Subnet Mask : Reserved
  • Hosts per Network : Multicast Addresses

Class E (Experimental Addresses)

  • IP Range: 240.0.0.0 to 255.255.255.255
  • Usage: Reserved for experimental or research purposes and not used in general networking.
  • Default Subnet Mask : Reserved
  • Hosts per Network :Experimental and Research

Subnetting

A subnet (short for "subnetwork") is a logical division of an IP network into smaller, more manageable segments. Subnetting allows network administrators to organize a larger network into smaller, efficient sub-networks, improving performance and security.

An IPv4 address is 32 bits long, typically written as four octets (e.g., 192.168.1.0).

Subnet Mask Defines which portion of the IP address refers to the network and which part refers to the host within that network. It is also written in dotted decimal format (e.g., 255.255.255.0).

The subnet mask uses 1s to identify the network portion and 0s to identify the host portion.

Example:

  • IP Address: 192.168.1.10
  • Subnet Mask: 255.255.255.0
  • Step-by-Step:
    Convert IP Address and Subnet Mask to Binary:
    192.168.1.10 = 11000000.10101000.00000001.00001010
    255.255.255.0 = 11111111.11111111.11111111.00000000
  • Network Address
    By performing a bitwise AND operation between the IP address and subnet mask, the network address is 192.168.1.0.
  • Subnet Information
    This subnet allows for 256 IP addresses (from 192.168.1.0 to 192.168.1.255)
    but the first address (192.168.1.0) is reserved for the network
    and the last address (192.168.1.255) is reserved for broadcast.
    The valid host range is from 192.168.1.1 to 192.168.1.254.

To subnet the IP address 192.168.1.0/27, let's break it down:

Understanding the /27 Prefix:

A /27 subnet mask means that the first 27 bits of the IP address are used for the network part, and the remaining 5 bits are used for hosts. The subnet mask for /27 is:

Copy code

255.255.255.224

This gives us 32 total addresses in each subnet (2^5 = 32). Out of these, 30 addresses can be assigned to hosts (2 addresses are reserved: one for the network address and one for the broadcast address).

  • Subnetting the 192.168.1.0/27 Network:
    The network address is 192.168.1.0 and the subnet mask is 255.255.255.224.
    The first address of the subnet is the Network Address.
    The last address of the subnet is the Broadcast Address.
    The remaining addresses are available for host assignment.
  • Calculating Subnets:
    Since the subnet mask is /27, the network is divided into 8 subnets of 32 addresses each. Below is the breakdown of each subnet.
Subnet Number Network Address First Usable IP Last Usable IP Broadcast Address Number of Hosts
1 192.168.1.0 192.168.1.1 192.168.1.30 192.168.1.31 30
2 192.168.1.32 192.168.1.33 192.168.1.62 192.168.1.63 30
3 192.168.1.64 192.168.1.65 192.168.1.94 192.168.1.95 30
4 192.168.1.96 192.168.1.97 192.168.1.126 192.168.1.127 30
5 192.168.1.128 192.168.1.129 192.168.1.158 192.168.1.159 30
6 192.168.1.160 192.168.1.161 192.168.1.190 192.168.1.191 30
7 192.168.1.192 192.168.1.193 192.168.1.222 192.168.1.223 30
8 192.168.1.224 192.168.1.225 192.168.1.254 192.168.1.255 30
  • Subnet Details:
    Total Subnets: 8
    Hosts per Subnet: 30
    Subnet Mask: 255.255.255.224 or /27
    Network Size: 32 addresses per subnet (30 usable for hosts)
    Usable IP addresses in the subnets can be  assign  to devices, like computers, printers, or other network devices.

IPv4 has several advantages

Mature and Well-Established: IPv4 has been in use since the 1980s, making it highly reliable, well-supported, and compatible with almost all devices and networks worldwide.

Simple and Lightweight: Its 32-bit address structure is relatively simple, which helps in easy implementation and minimal processing overhead for devices and routers.

Wide Adoption: IPv4 is universally deployed, meaning that virtually all internet services, devices, and networks support it, ensuring global connectivity.

Established Routing Infrastructure: The routing mechanisms and protocols (e.g., OSPF, BGP) in IPv4 are well-understood, efficient, and have been optimized over time.

Extensive Documentation and Tools: Due to its long history, there is an abundance of tools, tutorials, and documentation available for IPv4, making it easier to troubleshoot and manage networks.

IPv4 has several disadvantages

Limited Address Space: IPv4 uses 32-bit addresses, which allows for only about 4.3 billion unique IP addresses. With the growing number of devices, this address space is quickly exhausted.

Address Exhaustion: Due to the limited number of IPv4 addresses, many organizations rely on techniques like NAT (Network Address Translation) to share a single public IP address, which can complicate network management and performance.

Inefficient Routing: IPv4 addresses are not as efficient for routing as they could be, leading to increased overhead in routing tables and slower processing times.

Security Issues: IPv4 was designed without strong built-in security features, and while security protocols like IPsec can be added, they are not universally implemented.

Network Configuration Complexity: IPv4 networks often require manual configuration for tasks like assigning IP addresses, making management more difficult as networks grow.


IPV6

IPv6 (Internet Protocol version 6) is the most recent version of the Internet Protocol (IP), designed to address the limitations of its predecessor, IPv4.

IPv6 uses 128-bit addresses, allowing for a vastly larger address space—around 340 undecillion (3.4×10²⁸) unique IP addresses—compared to the 32-bit address space of IPv4.

This expansion was necessary due to the exhaustion of IPv4 addresses. IPv6 also simplifies network configuration, improves security features (like mandatory IPsec encryption), and supports better routing and network efficiency.

The address format is typically written in eight groups of four hexadecimal digits, separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).


ICT Comparison ERD and DFD

Comparison of Entity-Relationship Diagram (ERD) and Data Flow Diagram (DFD)

Entity-Relationship Diagrams (ERD) and Data Flow Diagrams (DFD) are both widely used in system analysis and design, but they serve different purposes and represent different aspects of the system.

Aspect Entity-Relationship Diagram (ERD) Data Flow Diagram (DFD)
Purpose Describes the data and relationships between entities in a system. Describes the flow of data and the processes that transform the data.
Focus Data structure and relationships. Data processes and movement.
Type of Diagram Static diagram. Dynamic diagram.
Representation Entities (represented as rectangles), relationships (represented as diamonds), attributes (represented as ovals). Processes (represented as circles or rectangles), data flows (represented as arrows), data stores (represented as open-ended rectangles), external entities (represented as squares).
Primary Concern The structure of the system's data. The flow and processing of data within the system.
Level of Detail Typically shows high-level entities and relationships; does not show processes or workflows. Often shows multiple levels of abstraction (context-level DFD, child DFDs).
Focus Area Entities (e.g., Customers, Orders), their attributes, and relationships (e.g., one-to-many, many-to-many). Processes (e.g., Order Processing, Inventory Management), data flows, and interactions between entities and systems.
Use Case Used to model the data structure of a system, often in database design. Used to model the data flow and processes of a system, especially in system or software design.
Best Suited For Conceptualizing databases, designing relational databases, and representing business rules. Representing business processes, understanding system requirements, and defining how data moves through a system.
Level of Abstraction More abstract, focusing on "what" data exists and "how" it's related. Focuses on "how" data flows and is processed within the system.
Tools Used Often used in Database Design tools like ERwin, Microsoft Visio, or UML. Often used in process modeling tools or software like Microsoft Visio, Lucidchart, or structured analysis methods.
Example Entities: Customer, Order; Relationships: Customer places Order. Process: Order Processing, Data Flow: Order Data, External Entity: Customer.

Tailor made software and Off the shelf software

Tailor-made software (Custom software / Bespoke software) and Off-the-shelf software

Bespoke Vs Off the Shelf


Tailor-Made Software (Custom Software/Bespoke Software)

Tailor made software is specifically developed to meet the unique needs and requirements of a particular business or organization. It is built using variety of programming languages, frameworks and tools from scratch or heavily customized to fit the specific workflows, processes, and goals of the company.

Off-the-Shelf Software (Standard Software)

It is also known as commercial off-the-shelf (COTS). Off the shelf software is developed and pre-packaged by a vendor to address the needs of a broad audience or market segment. It comes with set of generic feature and templates and  ready to use and can be purchased or downloaded directly.


Factor Tailor-Made Software Off-the-Shelf Software
Customisation High, fully tailored to needs Limited customisation
Cost High upfront cost, ongoing maintenance Lower upfront cost, subscription/license fee
Time to Implement Longer, months or more Shorter, days or weeks
Scalability High, adaptable to growth Moderate, but may require additional tools
Maintenance and Support In-house or outsourced may need internal team Vendor-provided support but generic
Security Can be custom-designed for specific needs Vendor-managed, may face broad security risks
Functionality Exactly what you need May not fit all needs, some compromises
User Experience Custom UX/UI for your users Generic UX/UI
Updates & Upgrades Managed internally, flexibility Regular vendor updates, may lack flexibility
Risk High development risk, but high reward Lower risk, but potential limitations
Vendor Dependency Low, unless outsourcing maintenance High, dependent on vendor
Compliance Tailored to compliance needs May require modifications for specific needs