I'm trying to learn buddy allocation and whilst I think I understand the basics of it, there is one problem exercise with which I'm struggling with.
So I have an 8K block and I'm using buddy allocation trying to always allocate to the leftmost free memory area.. and I need to allocate a 5K memory block.
Do I split the 4K block into two 2K blocks, and take (from the left) the 1k, 2k, 2k blocks, or do I split the middle 2k block into two 1k blocks and take the 4k and the first 1k block from the right? Or do i simply take the 2k and 4k blocks that I have now?
Or is this type of allocation simply not possible if I need to make use of the whole 8k block (since the first 1k block is being used)?