PRACTICE SET
Operating Systems Practice Set 3
Unit 3 · Memory Management
Time: 45 MinutesTotal Marks: 25
Note: Answer all questions. Write your own answer first, then compare it with the answer given below each question.
SECTION A
1.Answer all questions in brief. 2 × 5 = 10| Q.No | Questions | Marks |
|---|
| (a) | A process has relocation register value 14000. What physical address does the MMU produce for logical address 346? | 2 | | Answer The MMU adds the relocation register to every logical address: 14000 + 346 = 14346. The program only ever sees logical addresses; the physical address is formed in hardware at run time. | | (b) | Differentiate between internal and external fragmentation. | 2 | | Answer Internal fragmentation is unused space inside an allocated block, for example the unused part of the last page of a process. External fragmentation is free memory split into many small holes between allocated blocks, so a request cannot be met even though the total free space is enough. Paging removes external fragmentation; compaction reduces it. | | (c) | What is a TLB and why is it used? | 2 | | Answer The Translation Look-aside Buffer is a small, fast associative cache of recent page-table entries. Without it every memory access needs an extra access to the page table in memory; with a TLB hit the frame number is found almost at once, so paging stays fast. | | (d) | What is a page fault? | 2 | | Answer A page fault is the trap raised when a process accesses a page that is not in main memory (its valid bit is off). The operating system finds the page on disk, loads it into a free frame (replacing a page if needed), updates the page table and restarts the instruction. | | (e) | What is Belady's anomaly? | 2 | | Answer Belady's anomaly is the surprising case where giving a process more frames increases the number of page faults. It can occur with FIFO replacement (for example 9 faults with 3 frames but 10 with 4 frames on the string 1,2,3,4,1,2,5,1,2,3,4,5). LRU and Optimal never show it. |
SECTION B
2.Answer all questions. 5 × 3 = 15| Q.No | Questions | Marks |
|---|
| (a) | In a paged system the page size is 1 KB (1024 bytes). Find the page number and offset for logical address 3000. If page 2 is in frame 5, find the physical address. | 5 | | Answer Page number = 3000 ÷ 1024 = 2 (integer part). Offset = 3000 − 2 × 1024 = 3000 − 2048 = 952. Page 2 is in frame 5, so the physical address = 5 × 1024 + 952 = 5120 + 952 = 6072. | | (b) | For the reference string 1, 3, 0, 3, 5, 6, 3 with 3 frames, find the number of page faults using FIFO, LRU and Optimal replacement. | 5 | | Answer FIFO: 1 F [1], 3 F [1,3], 0 F [1,3,0], 3 hit, 5 F replaces 1 → [3,0,5], 6 F replaces 3 → [0,5,6], 3 F replaces 0 → [5,6,3]. Page faults = 6. LRU: 1 F, 3 F, 0 F, 3 hit, 5 F replaces 1 (least recently used) → [3,0,5], 6 F replaces 0 → [3,5,6], 3 hit. Page faults = 5. Optimal: 1 F, 3 F, 0 F, 3 hit, 5 F replaces 1 (never used again) → [3,0,5], 6 F replaces 0 (never used again) → [3,5,6], 3 hit. Page faults = 5. | | (c) | Memory access takes 100 ns and a TLB lookup takes 20 ns. If the TLB hit ratio is 80%, find the effective memory access time. | 5 | | Answer On a TLB hit: 20 + 100 = 120 ns (TLB lookup, then the memory access). On a TLB miss: 20 + 100 + 100 = 220 ns (TLB lookup, page table access, then the memory access). Effective access time = 0.8 × 120 + 0.2 × 220 = 96 + 44 = 140 ns. Compared with 200 ns for paging without a TLB, the TLB saves 60 ns per access. |
|