OPERATING
SYSTEM:
CSET209
Multilevel paging
Segmentation
CONTENT
Segmented paging
PROBLEM WITH SINGLE-LEVEL PAGING
For 64-bit systems, the page table would be even larger, making it impractical to store in
contiguous memory.
S
MULTILEVEL PAGING
Multilevel paging is a paging scheme where there exists a hierarchy of page tables.
The need for multilevel paging arises when-
The size of page table is greater than the frame size.
As a result, the page table can not be stored in a single frame in main memory.
S
MULTILEVEL PAGING:
S
MULTILEVEL PAGING: WORKING
The page table having size greater than the frame size is divided into several parts.
The size of each part is same as frame size except possibly the last part.
The pages of page table are then stored in different frames of the main memory.
To keep track of the frames storing the pages of the divided page table, another page table is
maintained.
As a result, the hierarchy of page tables get generated.
Multilevel paging is done till the level is reached where the entire page table can be stored in a
single frame.
ADVANTAGES OF MULTILEVEL PAGING
✅ Reduces memory overhead – Only necessary portions of the page table are kept in RAM.
✅ Efficient use of memory – Unused page table entries are not allocated.
✅ Scalability – Works well for 64-bit address spaces, which require very large page tables.
✅ Improves performance – Reduces wastage in memory allocation for large processes.
S
ILLUSTRATION OF MULTILEVEL PAGING
Consider a system using paging scheme where- Number of Frames in Main Memory-
Number of frames in main memory
Logical Address Space = 4 GB = Size of main memory / Frame size
= 16 TB / 4 KB
Physical Address Space = 16 TB = 232 frames
Thus, Number of bits in frame number = 32 bits
Page size = 4 KB
Number of Bits in Page Offset-
Number of Bits in Physical Address-
We have,
Size of main memory Page size
= Physical Address Space = 4 KB
= 16 TB = 212 B
= 244 B Thus, Number of bits in page offset = 12 bits
Thus, Number of bits in physical address = 44 bits
S
ILLUSTRATION OF MULTILEVEL PAGING
So, Physical address is-
Inner Page Table Size-
Number of Pages of Process-
Inner page table keeps track of the frames storing the
Number of pages the process is divided pages of process.
= Process size / Page size Inner Page table size
= 4 GB / 4 KB = Number of entries in inner page table x Page table entry
= 220 pages size
= Number of pages the process is divided x Number of bits
in frame number
= 220 x 32 bits
= 220 x 4 bytes
= 4 MB
S
ILLUSTRATION OF MULTILEVEL PAGING
Number of Page Table Entries in One Page of
Number of Pages of Inner Page Table-
Inner Page Table-
Number of pages the inner page table is divided
Number of page table entries in one page of inner page
= Inner page table size / Page size
table
= 4 MB / 4 KB
= Page size / Page table entry size
= 210 pages
= Page size / Number of bits in frame number
= 4 KB / 32 bits
= 4 KB / 4 B
Number of Bits Required to Search an Entry =Outer
210 Page Table Size-
in One Page of Inner Page Table-
Outer page table is required to keep track of the frames
One page of inner page table contains 210 entries. storing the pages of inner page table.
Thus, Outer Page table size
Number of bits required to search a particular entry in one = Number of entries in outer page table x Page table entry
page of inner page table = 10 bits size
= Number of pages the inner page table is divided x
Number of bits in frame number
= 210 x 32 bits
= 210 x 4 bytes
= 4 KB
S
NUMBER OF BITS REQUIRED TO SEARCH AN ENTRY IN OUTER
PAGE TABLE
S
SEGMENTATION
Like Paging, Segmentation is another non-contiguous memory allocation technique.
In segmentation, process is not divided blindly into fixed size pages.
Rather, the process is divided into modules for better visualization.
Segmentation is a variable size partitioning scheme.
In segmentation, secondary memory and main memory are divided into partitions of
unequal size.
The size of partitions depend on the length of modules.
The partitions of secondary memory are called as segments
S
SEGMENTATION: EXAMPLE
S
SEGMENT TABLE
Segment table is a table that stores the information about each segment of the process.
It has two columns.
First column stores the size or length of the segment.
Second column stores the base address or starting address of the segment in the main memory.
Segment table is stored as a separate segment in the main memory.
Segment table base register (STBR) stores the base address of the segment table.
S
SEGMENT TABLE
S
SEGMENT TABLE
S
TRANSLATING LOGICAL ADDRESS INTO PHYSICAL
ADDRESS
•CPU always generates a logical address.
•A physical address is needed to access the main memory.
Step-01:
CPU generates a logical address consisting of two parts-
1.Segment Number
2.Segment Offset
•Segment Number specifies the specific segment of the process from which CPU wants to read the data.
•Segment Offset specifies the specific word in the segment that CPU wants to read.
S
TRANSLATING LOGICAL ADDRESS INTO PHYSICAL
ADDRESS
Step-02: For the generated segment number, corresponding entry is located in the segment table.
Then, segment offset is compared with the limit (size) of the segment.
Now, two cases are possible-
Case-01: Segment Offset >= Limit
If segment offset is found to be greater than or equal to the limit, a trap is generated.
Case-02: Segment Offset < Limit
• If segment offset is found to be smaller than the limit, then request is treated as a valid reque
• The segment offset must always lie in the range [0, limit-1],
• Then, segment offset is added with the base address of the segment.
• The result obtained after addition is the address of the memory location storing the required w
S
TRANSLATING LOGICAL ADDRESS INTO PHYSICAL
ADDRESS
S
TRANSLATING LOGICAL ADDRESS INTO PHYSICAL
ADDRESS
Advantages-
The advantages of segmentation are-
•It allows to divide the program into modules which provides better visualization.
•Segment table consumes less space as compared to page table in paging.
•It solves the problem of internal fragmentation.
Disadvantages-
The disadvantages of segmentation are-
•There is an overhead of maintaining a segment table for each process.
•The time taken to fetch the instruction increases since now two memory accesses are
required.
•Segments of unequal size are not suited for swapping.
•It suffers from external fragmentation as the free space gets broken down into smaller
pieces with the processes being loaded and removed from the main memory.
EXAMPLE
CONSIDER THE FOLLOWING SEGMENT TABLE-
Segm
ent Limit Base
No.
121
0 700
9
230
1 14
0
Which of the following logical address will produce
2 100 90
trap addressing error?
132
3 580
A. 0, 430 7
B. 1, 11 195
C. 2, 100 4 96
2
D. 3, 425
E. 4, 95
EXAMPLE
CONSIDER THE FOLLOWING SEGMENT TABLE-
Segm
ent Limit Base
No.
121
0 700
9
230
1 14
0
Which of the following logical address will produce
2 100 90
trap addressing error?
132
3 580
A. 0, 430 7
B. 1, 11 195
C. 2, 100 4 96
2
D. 3, 425
E. 4, 95
Calculate the physical address if no trap is
S
SEGMENTATION AND PAGING
Segmented paging is a scheme that implements the combination of segmentation and
paging.
• Process is first divided into segments and then each segment is divided into pages.
• These pages are then stored in the frames of main memory.
• A page table exists for each segment that keeps track of the frames storing the pages of
that segment.
• Each page table occupies one frame in the main memory.
• Number of entries in the page table of a segment = Number of pages that segment is
divided.
• A segment table exists that keeps track of the frames storing the page tables of
segments.
• Number of entries in the segment table of a process = Number of segments that process
is divided.
• The base address of the segment table is stored in the segment table base register.
S
TRANSLATING LOGICAL ADDRESS INTO PHYSICAL
ADDRESS
S
TRANSLATING LOGICAL ADDRESS INTO PHYSICAL
ADDRESS
Advantages-
The advantages of segmented paging are-
• Segment table contains only one entry corresponding to each segment.
• It reduces memory usage.
• The size of Page Table is limited by the segment size.
• It solves the problem of external fragmentation.
Disadvantages-
The disadvantages of segmented paging are-
• Segmented paging suffers from internal fragmentation.
• The complexity level is much higher as compared to paging.
Thankyou