Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Segmented paging
2.1.
Advantages of Segmented Paging
2.2.
Disadvantages of Segmented Paging
3.
Paged Segmentation
3.1.
Advantages of Paged Segmentation
3.2.
Disadvantages of  Paged Segmentation
4.
Frequently Asked Questions
4.1.
What is segmented paging? 
4.2.
What are the advantages of segmented paging?
4.3.
What is Segmentation with paging techniques?
4.4.
What is the difference between paging and segmentation?
5.
Conclusion
Last Updated: Mar 27, 2024
Medium

Paged Segmentation and Segmented Paging

Introduction

Paged segmentation and segmented paging are two memory management techniques that offer the advantages of both paging and segmentation, and 

A memory management technique known as Segmentation with Paging in OS combines the benefits of both segmentation and paging. 

Paged Segmentation and Segmented Paging

The main memory is split into variable-size segments, which are subsequently partitioned into segmentation with paging in os"smaller fixed-size disk pages. Each segment has a page table, and each process has many page tables.

Each table includes information for each segment page, whereas the segment table has information for each segment. Page tables are linked to segment tables and segment tables to individual pages within a segment.

Segmented paging

Segmented paging is a way to manage computer memory that breaks it into small chunks called segments, and within each segment, there are fixed-sized pages. It's like dividing a big book into chapters, and each chapter into pages, to make it easier to read and manage.

Pages are created from segments. Implementation necessitates STR (segment table register) and PMT (page map table). 
Each virtual address in this method consists of a segment number, a page number, and an offset within that page. The segment number indexes into the segment table, which returns the page table's base address for that segment. 
The page number is an index into the page table, each item of which represents a page frame. The physical address is obtained by adding the PFN (page frame number) and the offset. As a result, addressing may be defined by the function:

va=(s,p,d)

here,

va is the virtual address,

s determines the number of segments (size of ST), 

p determines the number of pages per segment (size of PT), 

d determines page size.

Segmented paging
address_map(s, p, w)
{
pa = *(*(STR+s)+p)+w; 
return pa;
}

Advantages of Segmented Paging

The benefits of segmented paging are as follows:

  • Each segment is represented by a single entry in the segment table. It lowers memory use
  • The segment size determines the size of the Page Table
  • It reduce the issue of external fragmentation

Disadvantages of Segmented Paging

The downsides of segmented paging are as follows:

  • Internal fragmentation plagues segmented paging
  • When compared to paging, the complexity level is substantially higher
  • Managing both segmentation and paging tables increases overhead
  • Require additional effort to design and implement

Paged Segmentation

Paged Segmentation is used to solve the problem segmented paging has. In this, every process has a different number of segments. When the segment table is large, it causes external fragmentation due to varying segment table sizes. So to solve this, the process requires the segment table to be paged. Also, the page table can have invalid pages even after Segmentation paging. So paged Segmentation is used instead of multi-level paging along with segmented paging, giving the optimum solution to the larger tables.

Paged Segmentation

Advantages of Paged Segmentation

  • It offers protection in specific segments
  • It uses less memory than paging
  • There is no external fragmentation
  • It optimizes resource allocation
  • Easiness in adding or removing segments and pages
  • It also facilitates multi-programming
  • It supports large programs

Disadvantages of  Paged Segmentation

  • It is costly
  • In the case of swapping, segments with different sizes are not good
  • Programmer intervention is required
  • introduce additional overhead in terms of memory and processing
  • adds complexity to memory management
  • fragmentation can still occur over time 
  • The learning curve is steep

Frequently Asked Questions

What is segmented paging? 

The primary memory is separated into variable-size segments, further divided into fixed-size pages in Segmented Paging. Pages are more compact than segments. Every segment has a page table. Hence each program has numerous page tables.

What are the advantages of segmented paging?

The fundamental advantage of segmented paging is that it uses less memory. It does not create external fragmentation because it allocates fixed-size pages. It simplifies memory allocations.

What is Segmentation with paging techniques?

Segmentation with paging is a way to manage computer memory. It splits memory into segments, and each segment into smaller pieces called pages. This helps use memory efficiently and adds security and flexibility to how programs use memory.

What is the difference between paging and segmentation?

Paging divides the process address space into pages, while segmentation does it into sections. The operating system handles paging, while segmentation relies on the compiler. Typically, paging is considered faster than segmentation.

Conclusion

This article extensively discussed Segmented Paging and its advantages and disadvantages. We briefly discussed segmentation and paging as well.

Recommended Reading:

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and AlgorithmsCompetitive Programming etc., as well as some Contests, Test SeriesInterview Bundles, and some Interview Experiences curated by top Industry Experts.

Live masterclass