Abstract:The buddy system implemented in the Linux kernel is studied, and the process of buddy algorithm is demonstrated with examples. There are three levels of data structure dedicated to manage page frames in physical address space. Firstly, these data structures and their relationships are presented. Then, the buddy algorithm used to allocate and deallocate page frames is described in detail. As far as a memory block to be deallocated is concerned, how to calculate the index of its buddy and coalesced memory block is the key point of deallocating operation. Several conclusions pertaining to this calculation are dealt with and proved.