Operating System MCQs - Memory Management, Paging and Virtual Memory (Set 2)

Operating System MCQs - Memory Management, Paging and Virtual Memory (Set 2) - CodingHumans

This second set of Operating System MCQs covers memory management, from contiguous allocation and fragmentation to paging, segmentation and virtual memory. The numericals on page tables, TLB access time and page replacement are the kind that appear regularly in GATE, university exams and placement tests, and each one has its working shown.

How to practise: read each question and tap the option you think is correct. You will see right away whether you got it, along with a short explanation, and your score is tracked at the bottom of the screen. This set has 17 questions.

Topics covered in this set

  • Contiguous allocation and fragmentation
  • Paging, page tables and address translation
  • TLB and effective access time
  • Segmentation
  • Virtual memory and demand paging
  • Page replacement, Belady's anomaly and thrashing

Operating system MCQs with answers and explanations

Q1. Memory is divided into fixed-size partitions, and a 7 KB process is placed in a 10 KB partition. The unused 3 KB inside that partition is an example of what?

a) External fragmentation

b) Internal fragmentation

c) Thrashing

d) Compaction

Q2. Which technique directly removes external fragmentation in variable-partition contiguous allocation?

a) Increasing the page size

b) Using a TLB

c) Swapping in more processes

d) Compaction, which moves processes to merge free holes into one block

Q3. Which statement about paging is correct?

a) It eliminates external fragmentation but can still cause internal fragmentation in the last page

b) It eliminates both internal and external fragmentation

c) It eliminates internal fragmentation but causes external fragmentation

d) It requires each process to occupy contiguous physical frames

Q4. What is the main benefit of virtual memory?

a) It makes RAM access faster than cache

b) It removes the need for a page table

c) It allows a process to run even when only part of it is in physical memory

d) It prevents all page faults

Q5. What is the key property of an inverted page table?

a) It has one entry for each physical frame, shared by all processes

b) It has one entry for each virtual page of every process

c) It is stored entirely inside the TLB

d) It removes the need to store process IDs

Q6. A system shows very high paging activity, while CPU utilisation has dropped sharply after more processes were admitted. What is happening, and what helps?

a) Deadlock; preempt resources from a victim process

b) Thrashing; reduce the degree of multiprogramming or allocate frames based on working sets

c) Belady's anomaly; switch from LRU to FIFO

d) External fragmentation; perform compaction

Q7. Which page replacement algorithm can suffer from Belady's anomaly, where adding frames increases page faults?

a) LRU

b) Optimal

c) LFU with aging

d) FIFO

Q8. Free memory holes, in order, are 150 KB, 400 KB, 250 KB, 600 KB and 350 KB. A process requests 330 KB. Which hole does the best-fit strategy choose?

a) 400 KB

b) 600 KB

c) 350 KB

d) 250 KB

Q9. A logical address space has 64 pages of 1 KB each. How many bits are in a logical address?

a) 16

b) 6

c) 10

d) 64

Q10. A machine has 1 GB of physical memory and a page size of 4 KB. How many bits are needed for the frame number?

a) 12

b) 18

c) 20

d) 30

Q11. A system uses 32-bit logical addresses, 4 KB pages and 4-byte page table entries with a single-level page table. What is the size of one process's page table?

a) 1 MB

b) 4 KB

c) 4 MB

d) 16 MB

Q12. Using the segment table below, what physical address does logical address (segment 1, offset 450) map to?

Segment | Base | Limit
   0    | 1200 |  500
   1    | 2400 |  600
   2    |  900 |  200

a) 1650

b) 2400

c) Addressing error (trap)

d) 2850

Q13. TLB lookup takes 20 ns and a main memory access takes 100 ns. With a TLB hit ratio of 80% and a single-level page table, what is the effective memory access time?

a) 120 ns

b) 140 ns

c) 160 ns

d) 220 ns

Q14. With demand paging, memory access time is 200 ns, page fault service time is 8 ms and the page fault rate is 0.001. What is the effective access time, approximately?

a) About 8.2 microseconds

b) About 200 ns

c) About 8 ms

d) About 1.6 microseconds

Q15. How many page faults occur with FIFO replacement and 3 initially empty frames for the reference string below?

2, 3, 2, 1, 5, 2, 4, 5, 3, 2, 5, 2

a) 7

b) 8

c) 9

d) 10

Q16. For the same reference string and 3 initially empty frames, how many page faults occur with LRU replacement?

2, 3, 2, 1, 5, 2, 4, 5, 3, 2, 5, 2

a) 9

b) 6

c) 8

d) 7

Q17. How many page faults does the Optimal (OPT) algorithm produce with 4 initially empty frames for the reference string below?

1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

a) 8

b) 6

c) 10

d) 5

Quick revision notes

  • Fixed partitions cause internal fragmentation; variable partitions cause external fragmentation, fixed by compaction.
  • First fit takes the first big-enough hole, best fit the smallest, worst fit the largest.
  • Logical address bits = page number bits + offset bits; offset bits = log2(page size).
  • Page table size = number of pages x PTE size; large tables motivate multi-level or inverted page tables.
  • TLB EAT = h(t + m) + (1 - h)(t + 2m) for a single-level page table.
  • Demand paging EAT = (1 - p) x memory time + p x page fault service time.
  • FIFO can show Belady's anomaly; LRU and Optimal are stack algorithms and cannot.
  • Thrashing = too little memory per process; control it with the working set model or page-fault frequency.

Frequently asked questions

What is the difference between paging and segmentation?

Paging splits memory into fixed-size pages and frames that are invisible to the programmer, which removes external fragmentation. Segmentation splits a program into variable-size logical units such as code, stack and data, which matches the programmer's view but can cause external fragmentation.

Why is Optimal page replacement not used in real operating systems?

Optimal replacement needs to know which page will be used farthest in the future, which the OS cannot know in advance. It is used as a benchmark to judge how close practical algorithms like LRU and its approximations come to the best possible result.

Why does a TLB improve performance so much?

Without a TLB, every memory reference needs an extra memory access to read the page table. The TLB caches recent page-to-frame translations, and because programs show locality of reference, hit ratios are usually high, bringing effective access time close to a single memory access.

Comments

Answered 0/0Correct 0