33,7 → 33,6 |
#include <typedefs.h> |
#include <list.h> |
#include <debug.h> |
#include <print.h> |
|
/** Create buddy system |
* |
57,7 → 56,6 |
ASSERT(op->get_order); |
ASSERT(op->bisect); |
ASSERT(op->coalesce); |
ASSERT(op->mark_busy); |
|
/* |
* Allocate memory for structure describing the whole buddy system. |
85,28 → 83,6 |
return b; |
} |
|
/** Check if buddy system can allocate block |
* |
* @param b Buddy system pointer |
* @param i Size of the block (2^i) |
* |
* @return True if block can be allocated |
*/ |
bool buddy_system_can_alloc(buddy_system_t *b, __u8 i) { |
__u8 k; |
|
ASSERT(i < b->max_order); |
|
for (k=i; k < b->max_order; k++) { |
if (!list_empty(&b->order[k])) { |
return true; |
} |
} |
|
return false; |
|
} |
|
/** Allocate block from buddy system. |
* |
* @param b Buddy system pointer. |
127,7 → 103,6 |
if (!list_empty(&b->order[i])) { |
res = b->order[i].next; |
list_remove(res); |
b->op->mark_busy(b, res); |
return res; |
} |
|
161,9 → 136,7 |
|
/* |
* Return the other half to buddy system. |
* PROBLEM!!!! FILL FIND OTHER PART AS BUDDY AND LINK TOGETHER |
*/ |
b->op->mark_busy(b, res); |
buddy_system_free(b, hlp); |
|
return res; |
179,7 → 152,7 |
{ |
link_t *buddy, *hlp; |
__u8 i; |
|
|
/* |
* Determine block's order. |
*/ |
195,6 → 168,7 |
if (buddy) { |
|
ASSERT(b->op->get_order(b, buddy) == i); |
|
/* |
* Remove buddy from the list of order i. |
*/ |