What is a buddy system?
We are dividing the memory as powers of two therefore the division will be 2, 4, 8, 16, 32, 64, 128, 256...i.e. in powers of 2 as well as we are selecting the space which is smallest but large enough to hold a process. Assume we have 1M memory. If a process 70k enters we are able to choose the 128k which will be the best fit for the process. Thus divide the 1M into 512k each. After that a further division of 256k each in one 512k afterward one of the 256 is divided into further 128keach and place the process in that. Similarly to that if another process enters the division and placing will continue.
Process A enters of 0k
128 128 256 512
Process B enters of 35k
.
128 64 64 256 512
Process c enters of 80k
128 64 64 128 128 512
Process A terminates
64 64 128 128 512
Process D enters of 60k
64 64 128 128 512
Process B terminates
64 128 128 512
Process D terminates
128 128 512
Process C terminates
Subsequent to this all the free spaces will join together. Later than the two adjacent processes having same space completed they will combine together and at last when all the processes are over the 1M memory will get back.