- OS - Home
- OS - Overview
- OS - History
- OS - Evolution
- OS - Functions
- OS - Components
- OS - Structure
- OS - Architecture
- OS - Services
- OS - Properties
- Process Management
- Processes in Operating System
- States of a Process
- Process Schedulers
- Process Control Block
- Operations on Processes
- Process Suspension and Process Switching
- Process States and the Machine Cycle
- Inter Process Communication (IPC)
- Remote Procedure Call (RPC)
- Context Switching
- Threads
- Types of Threading
- Multi-threading
- System Calls
- Scheduling Algorithms
- Process Scheduling
- Types of Scheduling
- Scheduling Algorithms Overview
- FCFS Scheduling Algorithm
- SJF Scheduling Algorithm
- Round Robin Scheduling Algorithm
- HRRN Scheduling Algorithm
- Priority Scheduling Algorithm
- Multilevel Queue Scheduling
- Lottery Scheduling Algorithm
- Starvation and Aging
- Turn Around Time & Waiting Time
- Burst Time in SJF Scheduling
- Process Synchronization
- Process Synchronization
- Solutions For Process Synchronization
- Hardware-Based Solution
- Software-Based Solution
- Critical Section Problem
- Critical Section Synchronization
- Mutual Exclusion Synchronization
- Mutual Exclusion Using Interrupt Disabling
- Peterson's Algorithm
- Dekker's Algorithm
- Bakery Algorithm
- Semaphores
- Binary Semaphores
- Counting Semaphores
- Mutex
- Turn Variable
- Bounded Buffer Problem
- Reader Writer Locks
- Test and Set Lock
- Monitors
- Sleep and Wake
- Race Condition
- Classical Synchronization Problems
- Dining Philosophers Problem
- Producer Consumer Problem
- Sleeping Barber Problem
- Reader Writer Problem
- OS Deadlock
- Introduction to Deadlock
- Conditions for Deadlock
- Deadlock Handling
- Deadlock Prevention
- Deadlock Avoidance (Banker's Algorithm)
- Deadlock Detection and Recovery
- Deadlock Ignorance
- Resource Allocation Graph
- Livelock
- Memory Management
- Memory Management
- Logical and Physical Address
- Contiguous Memory Allocation
- Non-Contiguous Memory Allocation
- First Fit Algorithm
- Next Fit Algorithm
- Best Fit Algorithm
- Worst Fit Algorithm
- Buffering
- Fragmentation
- Compaction
- Virtual Memory
- Segmentation
- Paged Segmentation & Segmented Paging
- Buddy System
- Slab Allocation
- Overlays
- Free Space Management
- Locality of Reference
- Paging and Page Replacement
- Paging
- Demand Paging
- Page Table
- Page Replacement Algorithms
- Second Chance Page Replacement
- Optimal Page Replacement Algorithm
- Belady's Anomaly
- Thrashing
- Storage and File Management
- File Systems
- File Attributes
- Structures of Directory
- Linked Index Allocation
- Indexed Allocation
- Disk Scheduling Algorithms
- FCFS Disk Scheduling
- SSTF Disk Scheduling
- SCAN Disk Scheduling
- LOOK Disk Scheduling
- I/O Systems
- I/O Hardware
- I/O Software
- I/O Programmed
- I/O Interrupt-Initiated
- Direct Memory Access
- OS Types
- OS - Types
- OS - Batch Processing
- OS - Multiprogramming
- OS - Multitasking
- OS - Multiprocessing
- OS - Distributed
- OS - Real-Time
- OS - Single User
- OS - Monolithic
- OS - Embedded
- Popular Operating Systems
- OS - Hybrid
- OS - Zephyr
- OS - Nix
- OS - Linux
- OS - Blackberry
- OS - Garuda
- OS - Tails
- OS - Clustered
- OS - Haiku
- OS - AIX
- OS - Solus
- OS - Tizen
- OS - Bharat
- OS - Fire
- OS - Bliss
- OS - VxWorks
- Miscellaneous Topics
- OS - Security
- OS Questions Answers
- OS - Questions Answers
- OS Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
Operating System - Paged Segmentation and Segmented Paging
The paged segmentation and segmented paging are two hybrid memory management techniques that combine the benefits of both paging and segmentation. In previous sections, we have learned about paging and segmentation. This chapter will focus on explaining paged segmentation and segmented paging.
- Segmented Paging
- How Segmented Paging Works?
- Paged Segmentation
- How Paged Segmentation Works?
- Comparison: Paged Segmentation vs Segmented Paging
Segmented Paging
In segmented paging, the memory is divided into segments, and each segment is further divided into fixed-size pages. Combining the both techniques can overcome the limitations of each individual technique. The operating system maintains a segment table to keep track of the segments and their corresponding page tables. Each entry in the segment table contains a pointer to the page table for that segment.
How Segmented Paging Works?
The image below shows the working of segmented paging −
Here, we explain the steps involved in translating a logical address to a physical address using segmented paging:
1. Generating Logical Address
First the CPU generates a logical address that consists of three parts: segment number, page number, and offset within the page.
< Segment # , Page # , Offset >
- Segment Number − It identifies the segment to which the address belongs.
- Page Number − It identifies the specific page within the segment.
- Offset − It specifies the exact location within the page.
2. Segment Table Lookup
The segment number is used to index into the segment table to get the base address of the page table for that segment. The Segment # from the logical address is used as an index. The OS checks the limit to ensure the segment access is valid and retrieves the base address of the page table for that segment.
$\mathrm{\text{Base Address of Page Table} = \text{Segment Table}[\text{Segment #}].\text{Base Address}}$
Segment # -> Base Address of Page Table Segment 0 -> 0x2000 Segment 1 -> 0x3000 Segment 2 -> 0x4000 ...
3. Page Table Lookup
The page number is then used to index into the page table to get the frame number where the page is stored in physical memory. The page table will contain the mapping of page numbers to frame numbers for that segment.
$\mathrm{(\text{Physical Address} = (\text{Frame Number} \times \text{Page Size}) + \text{Offset}}$
Page # -> Frame # Page 0 -> Frame 0 Page 1 -> Frame 1 Page 2 -> Frame 3 ...
4. Physical Address Calculation
Finally, the physical address is calculated by combining the frame number with the offset within the page.
$\mathrm{\text{Physical Address} = (\text{Frame Number} \times \text{Page Size}) + \text{Offset}}$
Paged Segmentation
The paged segmentation is different from segmented paging. Here, the paged segmentation is used to refer the technique of paging the segment table. If a process has a massive number of segments, the Segment Table itself becomes too large to fit in one contiguous block of memory. So the segment table is treated as a process and is divided into pages. Each page of the segment table can be loaded into memory as needed, similar to how pages of a process are loaded in paging.
How Paged Segmentation Works?
The image below shows the working of paged segmentation −
Here, we explain the steps involved in translating a logical address to a physical address using paged segmentation:
1. Generating Logical Address
The CPU generates a logical address in the following format:
< Page Table Index (PTI), Segment Table Index (STI), Offset >
Here, the logical address consists of three parts: Page Table Index (PTI), Segment Table Index (STI), and Offset within the segment.
- Page Table Index (PTI) − It identifies the page of the segment table.
- Segment Table Index (STI) − It identifies the specific segment within that page.
- Offset − It specifies the exact location within the segment.
2. Outer Page Table
The outer page table (also called page directory) contains the base addresses of the pages of the segment table. Each entry in the outer page table points to a page of the segment table. This tells which segment table page contains the required segment entry.
Outer Page Table: PTI -> Base Address of Segment Table Page 0 -> 0x5000 1 -> 0x6000 2 -> 0x7000 ...
3. Accessing the Segment Table Page
Each page of the segment table contains multiple segment entries. Each segment entry stores the base address and limit of a segment.
Segment Table Page: STI -> Segment Base Address , Limit 0 -> 0x8000 , 0x1000 1 -> 0x9000 , 0x2000 2 -> 0xA000 , 0x3000 ...
The STI selects the correct segment entry inside the page. The offset is checked against the limit to ensure the access is valid. If the offset exceeds the limit, a segmentation fault occurs.
4. Physical Address Formation
The physical address is formed by adding the segment base address to the offset within the segment, provided the access is valid (i.e., offset is within the limit).
$\mathrm{\text{Physical Address} = \text{Segment Base Address} + \text{Offset}}$
Paged Segmentation vs Segmented Paging
The paged segmentation and segmented paging are two different concepts. Both are often used interchangeably, in general discussions about hybrid memory management techniques. However, in strict technical terms, they refer to different approaches to combining paging and segmentation. Here, we summarize the key differences between paged segmentation and segmented paging: −
| Aspect | Paged Segmentation | Segmented Paging |
|---|---|---|
| Definition | Paging is applied to the segment table itself. | Segmentation is applied to the pages of a process. |
| Structure | The segment table is divided into pages, and each page contains multiple segment entries. | The memory is divided into segments, and each segment is further divided into fixed-size pages. |
| Address Translation | Logical address consists of Page Table Index (PTI), Segment Table Index (STI), and Offset. | Logical address consists of Segment Number, Page Number, and Offset. |
| Use Case | Used when the segment table is too large to fit in memory as a single block. | Used to combine the benefits of both paging and segmentation for memory management. |
Conclusion
Both paged segmentation and segmented paging are hybrid memory management techniques that have benefits of both paging and segmentation. You can choose either technique based on your system requirements and design considerations.