Allocation Algorithm

Allocation Algorithm - Allocation Algorithm 7. If there is...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Allocation Algorithm 1. Round up requested size to the next 8 byte boundary (if size ==0 assume 1 byte data) 2. Add the size of the header and the footer: real_size = roundup8(requested size) + sizeof(header) + sizeof(footer) 3. Lookup the corresponding list list = real_size ≥ 512? 64:((real_size)>>3) 4. If the list is non empty and list <64, remove a block from that list and return it.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Allocation Algorithm 5. If the list is empty, search for a list with objects of larger size. If there is one non-empty list with larger objects, remove one of the objects and split it. Use one portion of the object to satisfy the allocation request and return the remainder to the corresponding list. 6. If the remainder is smaller than the size of the header plus the footer plus next plus previous making the object unusable, then do not split the object and use the entire object to satisfy the allocation.
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Allocation Algorithm 7. If there is not enough memory in the free lists to satisfy the allocation, then request memory from the OS using sbrk(). Round up the request of memory to the OS to a 16KB boundary. Free Algorithm 1. Check the footer of the left neighbor object (the object just before the object being freed) to see if it is also free. If that is the case, remove the left neighbor from its free list using the previous and next pointers and coalesce this object with the object being freed. Free Algorithm 2. Check the header of the right neighbor object (the object just after the object being freed) to see if it is also free. If that is the case, remove the right neighbor from its free list using the previous and next pointers and coalesce it with the object being freed. 3. Place the freed object in the corresponding free list and update the header and footer....
View Full Document

Page1 / 5

Allocation Algorithm - Allocation Algorithm 7. If there is...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online