1. Introduction

Segmentation and paging are two important memory management techniques, each solving different problems.

Segmentation provides a logical view of a program, while paging eliminates external fragmentation.

However:

  • Segmentation suffers from external fragmentation

  • Paging ignores the logical structure of programs

To combine the advantages of both approaches, operating systems use Segmentation with Paging.

2. What is Segmentation with Paging?

Segmentation with paging is a hybrid memory management technique in which:

  • A process is first divided into logical segments

  • Each segment is further divided into fixed-size pages

  • Pages are stored in physical memory frames

Key Idea

Program
   ↓
Segments
   ↓
Pages
   ↓
Frames

This combines the logical organization of segmentation with the efficient allocation of paging.

3. Why Combine Segmentation and Paging?

Problem with Segmentation

Logical Structure ✓

External Fragmentation ✗

Problem with Paging

No External Fragmentation ✓

Logical Structure ✗

Combined Approach

Logical Structure ✓

No External Fragmentation ✓

4. Program Structure

Suppose a process contains:

SegmentPurpose
Segment 0Code
Segment 1Data
Segment 2Stack
Segment 3Heap

Instead of storing these segments directly in memory, each segment is divided into pages.

Example:

Code Segment
   ↓
Page 0
Page 1
Page 2

Data Segment
   ↓
Page 0
Page 1

Stack Segment
   ↓
Page 0
Page 1

5. Memory Organization

Physical memory is divided into fixed-size frames.

Example:

Frame 0
Frame 1
Frame 2
Frame 3
Frame 4
Frame 5
Frame 6
Frame 7
...

Pages from different segments can be placed in any available frame.

Example:

Code Page 0 → Frame 5

Code Page 1 → Frame 2

Data Page 0 → Frame 8

Stack Page 0 → Frame 3

6. Logical Address Structure

In segmentation with paging, a logical address has three components:

Logical Address

=
(Segment Number,
 Page Number,
 Offset)

or

(s, p, d)

7. Components of Logical Address

7.1 Segment Number (s)

Identifies the segment.

Example:

Code Segment

Data Segment

Stack Segment

7.2 Page Number (p)

Identifies the page within the selected segment.

Example:

Code Segment

Page 0

Page 1

Page 2

7.3 Offset (d)

Identifies the exact location within the page.

Example:

Byte 50

inside a page.

8. Data Structures Used

Two levels of translation are required.

8.1 Segment Table

Maps:

Segment Number
        ↓
Page Table Address

Each segment has an entry in the segment table.

8.2 Page Table

Each segment has its own page table.

Maps:

Page Number
      ↓
Frame Number

Key Insight

One Segment

↓

One Page Table

9. Segment Table Structure

A segment table entry typically contains:

  • Base address of page table

  • Segment length

  • Protection information

Example:

SegmentPage Table Base
0PT0
1PT1
2PT2
3PT3

10. Page Table Structure

Each page table maps pages to frames.

Example:

Segment 1 Page Table

PageFrame
05
13
28
31

11. Address Translation Process

This is the most important concept.

Given:

Logical Address

(s, p, d)

the MMU performs translation in two stages.

12. Step-by-Step Address Translation

Step 1

Extract segment number.

s

Step 2

Access segment table.

Segment Number

↓

Page Table Address

Step 3

Use page number.

p

to access the selected page table.

Step 4

Obtain frame number.

Page Number

↓

Frame Number

Step 5

Combine frame number and offset.

(Frame Number, Offset)

to form the physical address.

13. Translation Flow

Logical Address

(s, p, d)

      ↓

Segment Table

      ↓

Page Table

      ↓

Frame Number

      ↓

Physical Address

14. Formula

After translation:

Physical Address

=
Frame Number + Offset

More precisely:

Physical Address

=
(Frame Number × Page Size)
+ Offset

15. Numerical Example

Given:

Logical Address

(s=1, p=2, d=50)

Segment Table:

Segment 1

↓

Page Table PT1

Page Table PT1:

PageFrame
05
13
28
31

Step 1

Segment:

s = 1

Select PT1.

Step 2

Page:

p = 2

Lookup:

Page 2 → Frame 8

Step 3

Offset:

d = 50

Final Physical Address

(Frame 8, Offset 50)

or

Physical Address

=
Frame 8 + Offset 50

16. Protection Mechanism

Segmentation provides protection at the segment level.

Example:

SegmentPermissions
CodeRead, Execute
DataRead, Write
StackRead, Write
Shared LibraryRead, Execute

This provides better security than pure paging.

17. Sharing Support

Entire segments can be shared between processes.

Example:

Shared Library Segment

used by:

Process A

Process B

Process C

Benefits:

  • Saves memory

  • Reduces duplication

  • Improves efficiency

18. Fragmentation Analysis

External Fragmentation

Pure segmentation:

External Fragmentation Exists

Segmentation with paging:

External Fragmentation Eliminated

because paging allocates fixed-size frames.

Internal Fragmentation

Still possible.

Example:

Last page partially filled

Thus:

External Fragmentation ✗

Internal Fragmentation ✓

19. Advantages

Maintains Logical Structure

Segments correspond to actual program modules.

Eliminates External Fragmentation

Paging removes scattered free-space problems.

Better Protection

Protection at both segment and page levels.

Better Sharing

Logical modules can be shared easily.

Efficient Memory Utilization

Combines strengths of both approaches.

20. Disadvantages

High Complexity

Two levels of translation.

Additional Memory Overhead

Requires:

  • Segment table

  • Multiple page tables

Slower Translation

More lookups compared to simple paging.

Complex Hardware Support

MMU becomes more sophisticated.

21. Comparison with Paging and Segmentation

FeaturePagingSegmentationSegmentation + Paging
Division BasisFixed PagesLogical SegmentsSegments + Pages
Logical ViewNoYesYes
External FragmentationNoYesNo
Internal FragmentationYesNoYes
ProtectionModerateGoodExcellent
SharingModerateGoodExcellent
ComplexityLowMediumHigh

22. Real-World Analogy

Think of a book.

Segmentation

Book

↓

Chapters

Each chapter represents a segment.

Paging

Chapter

↓

Pages

Each chapter is divided into pages.

Physical Memory

Pages stored on shelves

To find information:

Chapter
   ↓
Page
   ↓
Shelf Location

This is exactly how segmentation with paging works.

Most Important Point

Segmentation with Paging combines the logical view of segmentation and the efficient memory allocation of paging by dividing a process into segments and then dividing each segment into pages mapped onto physical memory frames.