Explain Buddy System

Q1. What is Buddy System?

Ans. The buddy system allocates memory from a fixed size segment consisting of physically contiguous pages. Memory is allocated from this segment using a power-of-2 allocator,

  1. Which satisfies requests in units sized as a power of 2.

For example:

4 KB, 8 KB, 16 KB, and so forth.

  1. A request in units not appropriately sized is rounded up to the next highest power of 2.

For example:

If a request for 11 KB is made, it is satisfied with a 16-KB segment.

  1. When smaller allocation needed than is available, current segment split into two buddies of next lower power of two, continue until appropriate sized segment available.

For example:

When kernel request 21 KB of memory.

Buddy System Allocation

Figure: Buddy system allocation

World is full of questions and we are trying to solve a few of them.

Leave a Reply

Your email address will not be published. Required fields are marked *