Paged Segmentation and Segmented Paging are two different memory management techniques that combine the benefits of paging and segmentation.
- Paged Segmentation is a memory management technique that divides a process’s address space into segments and then divides each segment into pages. This allows for a flexible allocation of memory, where each segment can have a different size, and each page can have a different size within a segment.
- Segmented Paging, on the other hand, is a memory management technique that divides the physical memory into pages, and then maps each logical address used by a process to a physical page. In this approach, segments are used to map virtual memory addresses to physical memory addresses, rather than dividing the virtual memory into pages.
- Both Paged Segmentation and Segmented Paging provide the benefits of paging, such as improved memory utilization, reduced fragmentation, and increased performance. They also provide the benefits of segmentation, such as increased flexibility in memory allocation, improved protection and security, and reduced overhead in memory management.
However, both techniques can also introduce additional complexity and overhead in the memory management process. The choice between Paged Segmentation and Segmented Paging depends on the specific requirements and constraints of a system, and often requires trade-offs between flexibility, performance, and overhead.
Major Limitation of Single Level Paging
A big challenge with single level paging is that if the logical address space is large, then the page table may take up a lot of space in main memory. For instance, consider that logical address is 32 bit and each page is 4 KB, the number of pages will be 2^20 pages. The page table without additional bits will be of the size 20 bits * 220 or 2.5 MB. Since each process has its own page table, a lot of memory will be consumed when single level paging is used. For a system with 64-bit logical address even a page table of single process will not fit in main memory. For a process with a large logical address space, a lot of its page table entries are invalid as a lot of the logical address space goes unused.
Page table with invalid entries
A solution to the problem is to use segmentation along with paging to reduce the size of page table. Traditionally, a program is divided into four segments, namely code segment, data segment, stack segment and heap segment.
Segments of a process
The size of the page table can be reduced by creating a page table for each segment. To accomplish this hardware support is required. The address provided by CPU will now be partitioned into segment no., page no. and offset.
The memory management unit (MMU) will use the segment table which will contain the address of page table(base) and limit. The page table will point to the page frames of the segments in main memory.
Advantages of Segmented Paging
- The page table size is reduced as pages are present only for data of segments, hence reducing the memory requirements.
- Gives a programmers view along with the advantages of paging.
- Reduces external fragmentation in comparison with segmentation.
- Since the entire segment need not be swapped out, the swapping out into virtual memory becomes easier .
Disadvantages of Segmented Paging
- Internal fragmentation still exists in pages.
- Extra hardware is required
- Translation becomes more sequential increasing the memory access time.
- External fragmentation occurs because of varying sizes of page tables and varying sizes of segment tables in today’s systems.
- In segmented paging, not every process has the same number of segments and the segment tables can be large in size which will cause external fragmentation due to the varying segment table sizes. To solve this problem, we use paged segmentation which requires the segment table to be paged. The logical address generated by the CPU will now consist of page no #1, segment no, page no #2 and offset.
- The page table even with segmented paging can have a lot of invalid pages. Instead of using multi level paging along with segmented paging, the problem of larger page table can be solved by directly applying multi level paging instead of segmented paging.
Advantages of Paged Segmentation
- No external fragmentation
- Reduced memory requirements as no. of pages limited to segment size.
- Page table size is smaller just like segmented paging,
- Similar to segmented paging, the entire segment need not be swapped out.
- Increased flexibility in memory allocation: Paged Segmentation allows for a flexible allocation of memory, where each segment can have a different size, and each page can have a different size within a segment.
- Improved protection and security: Paged Segmentation provides better protection and security by isolating each segment and its pages, preventing a single segment from affecting the entire process’s memory.
Increased program structure: Paged Segmentation provides a natural program structure, with each segment representing a different logical part of a program.
- Improved error detection and recovery: Paged Segmentation enables the detection of memory errors and the recovery of individual segments, rather than the entire process’s memory.
- Reduced overhead in memory management: Paged Segmentation reduces the overhead in memory management by eliminating the need to maintain a single, large page table for the entire process’s memory.
- Improved memory utilization: Paged Segmentation can improve memory utilization by reducing fragmentation and allowing for the allocation of larger blocks of contiguous memory to each segment.
Disadvantages of Paged Segmentation
- Internal fragmentation remains a problem.
- Hardware is complexer than segmented paging.
- Extra level of paging at first stage adds to the delay in memory access.
- Increased complexity in memory management: Paged Segmentation introduces additional complexity in the memory management process, as it requires the maintenance of multiple page tables for each segment, rather than a single page table for the entire process’s memory.
- Increased overhead in memory access: Paged Segmentation introduces additional overhead in memory access, as it requires multiple lookups in multiple page tables to access a single memory location.
- Reduced performance: Paged Segmentation can result in reduced performance, as the additional overhead in memory management and access can slow down the overall process.
- Increased storage overhead: Paged Segmentation requires additional storage overhead, as it requires additional data structures to store the multiple page tables for each segment.
- Increased code size: Paged Segmentation can result in increased code size, as the additional code required to manage the multiple page tables can take up valuable memory space.
- Reduced address space: Paged Segmentation can result in a reduced address space, as some of the available memory must be reserved for the storage of the multiple page tables.
Some popular books on Operating Systems that discuss Paged Segmentation include:
- Operating System Concepts by Abraham Silberschatz, Peter Baer Galvin, and Greg Gagne
- Modern Operating Systems by Andrew S. Tanenbaum
- Operating Systems: A Design-Oriented Approach by Charles Crowley
- Understanding the Linux Kernel by Daniel P. Bovet and Marco Cesati
- Operating Systems: Principles and Practice by Thomas Anderson and Michael Dahlin.
These books provide a comprehensive discussion of Paged Segmentation and its related concepts, as well as practical examples and implementation details. They are considered essential reading for anyone interested in the study of operating systems and memory management techniques.
Share your thoughts in the comments
Please Login to comment...