buddy: replace free-lists with binary tree
before this patch, the buddy allocator used a hybrid bitmap-freelist approach where free would use the bitmap to determine size, but all other operations we O(n) traversals of the free-list. now, both alloc and free use the bitmap exclusively for allocation.
This commit is contained in:
parent
9cf4b71559
commit
9222a373fc
5 changed files with 83 additions and 146 deletions
12
lib/math.c
12
lib/math.c
|
|
@ -22,14 +22,12 @@ size_t log2(size_t n)
|
|||
return sizeof(n) * 8 - __builtin_clzll(n) - 1;
|
||||
}
|
||||
|
||||
inline void bitmap_set(char *bitmap, size_t n)
|
||||
inline void bitmap_set(char *bitmap, size_t n, uint64_t b)
|
||||
{
|
||||
bitmap[n >> 3] |= (1 << (n & 7));
|
||||
}
|
||||
|
||||
inline void bitmap_clear(char *bitmap, size_t n)
|
||||
{
|
||||
bitmap[n >> 3] &= (~(1 << (n & 7)));
|
||||
if(b)
|
||||
bitmap[n >> 3] |= (1 << (n & 7));
|
||||
else
|
||||
bitmap[n >> 3] &= (~(1 << (n & 7)));
|
||||
}
|
||||
|
||||
inline uint8_t bitmap_get(char *bitmap, size_t n)
|
||||
|
|
|
|||
Loading…
Reference in a new issue