CS FundamentalsModerateGATE CS (PYQ pattern)

A slab allocator builds each slab from two contiguous 4 KB pages. A slab has a 16-byte header and holds as many 200-byte objects as fit; the leftover bytes are used for cache colouring, i.e. the first object is shifted by 0, 64, 128, ... bytes in successive slabs, as long as the shift does not exceed the leftover. How many objects does a slab hold and how many different colours (offsets) exist?

  1. A. 40 objects, 2 colours
  2. B. 40 objects, 3 colours
  3. C. 20 objects, 2 colours
  4. D. 40 objects, 4 colours

Correct answer: B. 40 objects, 3 colours

(8192 - 16) / 200 = 40 objects (8000 bytes), leaving 8192 - 16 - 8000 = 176 bytes. Shifts 0, 64 and 128 fit within 176 (192 does not), so 3 colours; 176 / 64 = 2 forgets the zero offset. 20 objects uses a single 4 KB page.

More Operating Systems questions

Exams that ask this topic