Rev 534 | Rev 686 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 534 | Rev 683 | ||
---|---|---|---|
Line 228... | Line 228... | ||
228 | * Insert block into the list of order i. |
228 | * Insert block into the list of order i. |
229 | */ |
229 | */ |
230 | list_append(block, &b->order[i]); |
230 | list_append(block, &b->order[i]); |
231 | 231 | ||
232 | } |
232 | } |
- | 233 | ||
- | 234 | ||
- | 235 | ||
- | 236 | /** Prints out structure of buddy system |
|
- | 237 | * |
|
- | 238 | * @param b Pointer to buddy system |
|
- | 239 | * @param es Element size |
|
- | 240 | */ |
|
- | 241 | void buddy_system_structure_print(buddy_system_t *b) { |
|
- | 242 | index_t i; |
|
- | 243 | count_t cnt, elem_count = 0, block_count = 0; |
|
- | 244 | link_t * cur; |
|
- | 245 | ||
- | 246 | ||
- | 247 | printf("Order\tStatistics\n"); |
|
- | 248 | printf("-----\t--------------------------------------\n"); |
|
- | 249 | ||
- | 250 | for (i=0;i < b->max_order; i++) { |
|
- | 251 | cnt = 0; |
|
- | 252 | if (!list_empty(&b->order[i])) { |
|
- | 253 | for (cur = b->order[i].next; cur != &b->order[i]; cur = cur->next) cnt++; |
|
- | 254 | } |
|
- | 255 | ||
- | 256 | printf("#%d:\t%d blocks available (%d elements per block)\n", i, cnt, 1 << i); |
|
- | 257 | ||
- | 258 | block_count += cnt; |
|
- | 259 | elem_count += (1 << i) * cnt; |
|
- | 260 | } |
|
- | 261 | printf("-----\t--------------------------------------\n"); |
|
- | 262 | printf("Buddy system contains %d elements (%d blocks)\n" , elem_count, block_count); |
|
- | 263 | ||
- | 264 | } |