- LPU MCA Semester 1
- CAP366
- Unit 7
CAP366 · Unit 7: Memory management
Paging, segmentation and segmentation with paging
10 practice questions · in the ETE syllabus
Key points
- Physical address = frame x page size + offset
- Segment address = base + offset, checked against limit
- Paging: internal fragmentation; segmentation: external
- EAT weights TLB hit and miss times
Paging divides logical memory into fixed-size pages and physical memory into frames of the same size. A logical address splits into a page number p and an offset d; the page table maps p to a frame f, and the physical address is f x page size + d. Example: with 4096-byte pages, logical address 20000 is page 4, offset 3616; if page 4 is in frame 11, the physical address is 11 x 4096 + 3616 = 48672.
Segmentation divides a program into variable-size logical units such as code, stack and data. A logical address is (segment, offset); the segment table gives a base and limit, and the offset must be below the limit. Paging suffers internal fragmentation, segmentation suffers external fragmentation. Segmentation with paging pages each segment, removing external fragmentation.
The TLB caches recent page-table entries. Effective access time = hit ratio x (TLB + memory) + miss ratio x (TLB + page-table accesses + memory). With 80% hits, 20 ns TLB and 100 ns memory: 0.8 x 120 + 0.2 x 220 = 140 ns.
Exam trap: the size of a single-level page table is the number of pages times the entry size, for example 2^20 x 4 bytes = 4 MB for 32-bit addresses and 4 KB pages.
Try two questions
The page size is 4096 bytes and a process has the page table with pages 0 to 5 mapped to frames 5, 9, 2, 7, 11 and 3. What physical address does the logical address 20000 map to?
- 52768
- 65056
- 32288
- 48672
Show the answer
D. 20000 = 4 * 4096 + 3616, so page 4, offset 3616. Page 4 maps to frame 11, giving 11 * 4096 + 3616 = 48672.
Why not A: That uses frame 12, which is not in the page table.
Why not B: That adds the whole logical address instead of only the offset.
Why not C: That uses frame 7, which belongs to page 3, but 20000 lies in page 4.
With 32-bit logical addresses, 4 KB pages and 4-byte page-table entries, how large is a single-level page table?
- 1 MB
- 16 MB
- 4 MB
- 4 KB
Show the answer
C. There are 2^20 pages, so the table has 2^20 entries of 4 bytes, which is 4 MB.
Why not A: 1 MB uses a wrong entry count.
Why not B: 16 MB assumes 16-byte entries.
Why not D: 4 KB would be one page and holds only 1024 entries.