Multiple choice

Consider a buddy system memory allocation where the size of a free memory segment is 256 KB, and the memory of kernel is 33 KB. To fulfill the request of memory allocation, a memory block of size M from free memory pool is allocated. What is the size of M?

  1. 33 KB

  2. 64 KB

  3. Two blocks, one of size 32 KB and other of size 1KB

  4. Two blocks each of size 32 KB

  5. 256 KB will be allocated

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In buddy system, the memory is allocated in units sized as a power of 2, i.e. 4 KB, 16KB and so on. If the request is not of the appropriate size, it is rounded up to the next higher power of 2. In the given case, 256 KB of memory splits into two blocks of 128 KB each. It is further divided into two 64 KB blocks. 64 KB is the next higher size of power of 2, which can satisfy 33 KB of memory. So, this 64 KB block is allocated to the kernel.