Buddy System


- used with virtual memory system either
- combination of fixed and dynamic
Compromise to overcome disadvantages of both fixed and dynamic partitioning schemes
<details><summary>

**Alogorithm**</summary>

1. Start with entire block
2. When request of size S is made
> ![](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa14d3c04-3016-4f0e-a409-5db1a488c95a%2FUntitled.png?table=block&id=1372aeb8-b364-4946-8e46-1cc0c6ac5fc5&cache=v2)
3. this process is repeated until the smallest block greater or equal to S is generated.
4. Two buddies are coalesced whenever both of them become de-allocated.
> Given the address and size of a block, the address of buddy is automatically determined. The address of a block and its buddy differ in exactly one bit position
> **binary branch framework and buddy(share one parent) is has different bit of final address**
</details>

![](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F95bed60f-0f6b-4160-993d-7960c4d49888%2FUntitled.png?table=block&id=f3fd7300-747a-4204-b62f-8b947fe5c206&cache=v2)
> modified form is used in UNIX SVR4 (and also in Linux) for kernel memory allocation (KMA)
> Smallest size of block is page

![](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F4085edf3-c409-4719-b832-70c192b29e91%2FUntitled.png?table=block&id=5c4d8207-1c56-4bf2-9233-3a534cbe810d&cache=v2)




