The short answer

Paging splits logical memory into fixed-size pages and physical memory into equal frames, then a page table maps each page to a frame. It hides memory from the programmer and avoids external fragmentation, yet it wastes a little space inside the last page. Segmentation splits a program into variable-size segments that match its logical parts, such as code, data, and stack, and a segment table stores each segment’s base and limit. In short, paging is a physical, hardware view, while segmentation is a logical, programmer-visible view.

Paging and segmentation are the two classic schemes an operating system uses to manage memory. Both turn up in every operating-systems course and GATE syllabus. Students often blur how each one maps a logical address and which kind of fragmentation each one causes.

The core question is simple. Should memory be divided by a fixed physical size, or by the program’s own logical structure? Paging takes the first path, while segmentation takes the second. This guide defines each scheme, compares them in detail, and shows where each one fits.

If the address side still feels fuzzy, it helps to know the difference between logical and physical memory addresses first. It also helps to be clear on internal versus external fragmentation, because that distinction is the heart of this comparison.

Two-panel diagram comparing paging, which maps fixed-size pages to frames through a page table, with segmentation, which maps variable-size segments through a segment table holding base and limit
Paging maps fixed-size pages to frames; segmentation maps variable-size logical segments via base and limit.

What is Paging?

Paging divides the logical (virtual) address space into fixed-size blocks called pages. It also divides physical memory into equal-size blocks called frames. Because a page and a frame are the same size, the operating system can drop any page into any free frame, so the pages of one process need not sit together in memory.

A page table records the mapping, since it stores the frame number that holds each page. Hardware decides the page size, and a single page table entry also carries flag bits, such as valid, dirty, and protection bits, alongside that frame number. Paging stays invisible to the programmer, so the process simply sees one linear address space. As a result, paging removes external fragmentation, yet it still wastes a little space inside the final, partly used page.

Advantages of paging:

  • No external fragmentation, because every frame is the same size and any frame fits any page.
  • Simple allocation, since the system just grabs any free frames from a list.
  • Invisible to the programmer, so each process sees one clean linear address space.
  • Easy to support virtual memory, because unused pages can stay on disk until needed.

Disadvantages of paging:

  • Internal fragmentation, since the last page of a process is rarely full.
  • Page-table overhead, because large address spaces need large tables in memory.
  • An extra memory lookup per access, unless a TLB caches recent translations.
  • No natural sharing or protection of logical units like a single function or array.

What is Segmentation?

Segmentation divides a program into variable-size segments that match its logical parts. So one segment holds the code, another holds the global data, another holds the stack, and so on. Each segment can grow or shrink on its own, which makes the layout flexible.

A segment table stores two values for every segment: a base address and a limit, that is, the segment’s length. Unlike paging, segmentation is visible to the programmer, because the logical address is an explicit pair of a segment number and an offset. Therefore the user, not the hardware, effectively sets each segment’s size. This logical view supports natural sharing and protection, since the system can mark a whole code segment as read-only or share it between processes. However, the variable sizes leave gaps in memory, so segmentation suffers from external fragmentation.

Advantages of segmentation:

  • No internal fragmentation, because each segment is sized to its actual contents.
  • A logical view that mirrors the program’s own structure, so code is easier to organise.
  • Natural sharing, since a shared library or code segment maps cleanly between processes.
  • Per-segment protection, because the segment table can mark a segment read-only or execute-only.

Disadvantages of segmentation:

  • External fragmentation, since variable-size segments leave scattered free gaps.
  • Harder allocation, because the system must find a hole large enough for each segment.
  • A limit check on every access, which adds a little work to address translation.
  • Visible complexity, as the programmer or compiler must manage the segment structure.

Paging vs Segmentation: Comparison Table

Comparison infographic listing block size, mapping table, fragmentation type, programmer visibility and protection for paging versus segmentation
Paging vs segmentation at a glance.
AspectPagingSegmentation
Block typeDivides the program into fixed-size pagesDivides the program into variable-size segments
Block size set byHardware decides the page sizeThe user or compiler specifies the segment size
Programmer viewInvisible to the programmerVisible to the programmer
SpeedFaster than segmentationSlower
Mapping tableA page table holds the page informationA segment table holds the segment information
Logical addressSplit into page number and page offsetSplit into segment number and segment offset
Address spaceOne linear address spaceMultiple linear address spaces
Table entryPage table entry has flag bits and a frame numberSegment table entry has protection bits and the segment base address
FragmentationSuffers from internal fragmentationSuffers from external fragmentation
Logical partitioningDoes not allow logical partitioning of application componentsAllows logical partitioning and protection of application components
Protection mechanismDoes not provide a per-unit protection mechanismProvides security associated with each segment
Limit fieldNot needed, because all pages share one sizeEach segment stores a limit, that is, its length
SharingPossible only at page boundariesNatural, since a whole logical segment can be shared
Reflects program structureNo, the split is purely physicalYes, each segment maps to a logical unit
Typical useVirtual memory in most modern operating systemsLogical grouping, often combined with paging

How Address Translation Works

Diagram showing paging splitting one logical address into page number and offset via a page table, and segmentation using an explicit segment number and offset via a segment table base and limit
How each scheme turns a logical address into a physical address.

The clearest way to see the gap is to follow one logical address through each scheme.

Under paging, the logical address is one plain number. The hardware splits it automatically into a page number and an offset. The page number indexes the page table to find the matching frame number. Then the hardware joins that frame number with the same offset to form the physical address. So the programmer never sees pages at all, because the split is automatic.

Under segmentation, the logical address is instead an explicit pair: a segment number and an offset within that segment. The segment number indexes the segment table to read the segment’s base and limit. First the hardware checks that the offset is below the limit, which protects against out-of-bounds access. Then it adds the base to the offset to form the physical address.

For a concrete example, picture a 4 KB page size. A logical address of 9000 falls in page 2, since 9000 divided by 4096 leaves an offset of 808. If the page table maps page 2 to frame 5, then the physical address becomes frame 5 plus offset 808. Segmentation handles the same task differently, because you would instead name the segment directly, say segment 3, offset 808, and the hardware would add segment 3’s base to 808.

Segmented Paging: The Best of Both

Paging and segmentation are not strictly rivals, so many real systems combine them. This hybrid is called segmented paging, and it gives the logical view of segmentation without the external fragmentation of pure segments.

The idea is simple. First the program is divided into logical segments, just as in segmentation. Then each segment is itself divided into fixed-size pages, just as in paging. As a result, the system keeps the clean logical structure and per-segment protection, yet it allocates physical memory in uniform frames. Therefore external fragmentation disappears, while the programmer still works with meaningful segments.

When to Use Paging or Segmentation

You rarely pick one scheme by hand, yet the trade-off still shapes real designs.

Choose paging when simple, efficient physical-memory use matters most. Virtual memory in modern operating systems leans on paging, because equal frames make allocation easy and remove external fragmentation. So paging suits the general case of running many processes side by side.

Choose segmentation when the logical structure and protection of a program matter most. Sharing a code library, isolating a stack, or marking data read-only all map cleanly onto segments. In practice, though, most systems combine the two through segmented paging, so they gain the strengths of each at once.

Interview Questions

Paging uses fixed-size pages and frames, so any free frame fits any page, which means no external gaps form. However, a process rarely fills its last page exactly, so the leftover space inside that final page is wasted. That wasted space inside an allocated block is internal fragmentation.

A segment table stores one entry per segment, and each entry holds a base address and a limit. The base gives the segment’s start in physical memory, while the limit gives its length. The hardware adds the base to the offset to translate the address, and it checks the offset against the limit for protection.

In paging, the logical address is a single number, and the hardware splits it automatically into a page number and an offset. In segmentation, the logical address is an explicit pair of a segment number and an offset. So paging hides the division, while segmentation exposes it to the programmer.

Because each segment maps to a logical unit, such as a code module or a data area, the system can protect or share that whole unit at once. For example, it can mark a code segment read-only or share it between processes. Paging splits memory by physical size, so it cannot align protection with logical units as cleanly.

Frequently Asked Questions

Paging allocates memory in fixed-size frames, so any free frame can hold any page. As a result, free memory never breaks into unusable odd-size gaps, which means external fragmentation cannot occur. The only cost is a little internal fragmentation in the last, partly used page of each process.

Yes, that flexibility is its main strength. Because each segment can grow or shrink on its own, segmentation handles varying data needs well. For example, a stack segment can expand while a fixed code segment stays put, so memory matches the program’s actual structure.

Internal fragmentation is the main challenge in paging, since a whole page is allocated even when the process does not fill it, which wastes memory. In addition, large address spaces need large page tables, so each lookup can add overhead unless a TLB caches recent translations.

Segmentation divides memory by data type or function, so each logical part of a program sits in its own segment. Because that layout mirrors how the code is actually organised, it is easier to understand and maintain. The structure also makes protection and sharing of individual modules more natural.

Paging usually scales better, because its uniform frames keep allocation simple even with many processes. Segmentation, by contrast, focuses on flexibility and logical structure. So large systems often combine the two through segmented paging, which gives scalable allocation along with a clean logical view.

Yes, many systems combine both in a scheme called segmented paging. First the program is split into logical segments, then each segment is split into fixed-size pages. So the design keeps the logical structure and protection of segmentation while gaining the efficient, fragmentation-free allocation of paging.

Wrapping Up

Paging and segmentation solve the same problem from opposite directions. Paging divides memory by a fixed physical size, while segmentation divides it by the program’s own logical structure.

Remember the simple rule: paging gives equal pages, one linear space, and internal fragmentation, whereas segmentation gives variable segments, a logical view, and external fragmentation. In practice, modern systems often blend the two through segmented paging. Still, knowing this core trade-off is enough to answer most exam and interview questions on the pair.

Related reading on DiffStudy:


Whatsapp-color Created with Sketch.

By Arun Kumar

Full Stack Developer with a BE in Computer Science, working with React, Next.js, Node.js, MongoDB, and AI/ML tools. Founder of DiffStudy — built to help CS students ace GATE and university exams, and keep developers up to date across AI, cloud, system design, web development, and every field of computer science. Every article is written from real hands-on experience, not just theory.

Leave a Reply

Your email address will not be published. Required fields are marked *


You cannot copy content of this page