Types of Buddy System
The Buddy System in memory control generally refers to a selected method used to allocate and deallocate memory blocks. However, within this framework, versions or adaptations may additionally exist relying on specific necessities or optimizations wished for distinctive structures. Here are a few types of Buddy Systems:
- Fibonacci Buddy System: A Fibonacci buddy system has block sizes of 16, 32, 48, 80, 128, and 208 bytes, with each block size equal to the total of the two blocks previous it. When a block is divided from one free list, its two portions are added to the two free lists that came before it. It can be minimized by bringing the allowable block sizes close together. Now, let’s look at an example to better grasp the Fibonacci buddy system. Assume the memory size is 377 kb. Then, 377 kb will be partitioned into 144 kb and 233 kb. Following that, 144 will be divided into (55 + 89), whereas 233 will be divided into (89 + 144). This separation will continue based on memory requirements.
- Binary Buddy System: The buddy system keeps track of the free blocks of each size (known as a free list) so that you can easily discover a block of the necessary size if one is available. If no blocks of the requested size are available, Allocate examines the first non-empty list for blocks of at least the requested size. In both cases, a block is deleted from the free list. For ex: The 512 KB memory size is initially partitioned into two active partitions of 256 KB each, with additional subdivisions based on a capacity of 2 to handle memory requests.
- Weighted Buddy System: In a weighted peer system, each memory block is associated with a weight, which represents its size relative to other blocks. When a memory allocation request occurs, the system searches for the appropriate block considering the size of the requested memory and the weight of the available blocks.
- Tertiary Buddy System : In a traditional buddy system, memory is divided into blocks of fixed size, usually a power of 2, and allocated to these blocks but the tertiary buddy system introduces a third memory structure, which allows flexibility large in memory allocation.
Buddy System – Memory Allocation Technique
Static partition techniques are limited by having a fixed number of active processes, and space use may not be optimal. The buddy system is a memory allocation and management technique that uses power-of-two increments. Assume the memory size is 2U and a size of S is required. In this article, we are going to discuss the Buddy System in detail along with examples, advantages, disadvantages, etc.