An algorithm to find the total number of units of memory allocated/deallocated by the server one after processing all the requests is Buddy memory allocation:
- A list contains all free nodes, which are all powers of 2 at all times.
- When the request of allocation comes, first go through with the smallest block than the bigger one.
- If such a block is found then the allocation is done, then traverse the list upwards until a big enough block is found.
- Then keep splitting the blocks-one for adding to the next free list, one to traverse down till we reach the target.
- If no allocations found, then simply return null.
Comments
Leave a comment