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,
- Which satisfies requests in units sized as a power of 2.
For example:
4 KB, 8 KB, 16 KB, and so forth.
- 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.
- 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.
Figure: Buddy system allocation