Changeset 328f2934 in mainline for generic/src/mm/buddy.c


Ignore:
Timestamp:
2005-12-04T19:37:13Z (20 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cf585c9
Parents:
d7ac642
Message:

Buddy allocator for physical memory complete implementation.
Tested on IA32, AMD64, MIPS32. RWLock Test #5 is not passed.
NOTE: Other architectures could be broken (but should not be)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/mm/buddy.c

    rd7ac642 r328f2934  
    3434#include <list.h>
    3535#include <debug.h>
     36#include <print.h>
    3637
    3738/** Create buddy system
     
    5758        ASSERT(op->bisect);
    5859        ASSERT(op->coalesce);
     60        ASSERT(op->mark_busy);
    5961
    6062        /*
     
    8486}
    8587
     88/** Check if buddy system can allocate block
     89 *
     90 * @param b Buddy system pointer
     91 * @param i Size of the block (2^i)
     92 *
     93 * @return True if block can be allocated
     94 */
     95bool buddy_system_can_alloc(buddy_system_t *b, __u8 i) {
     96        __u8 k;
     97       
     98        ASSERT(i < b->max_order);
     99       
     100        for (k=i; k < b->max_order; k++) {
     101                if (!list_empty(&b->order[k])) {
     102                        return true;
     103                }
     104        }
     105       
     106        return false;
     107       
     108}
     109
    86110/** Allocate block from buddy system.
    87111 *
     
    104128                res = b->order[i].next;
    105129                list_remove(res);
     130                b->op->mark_busy(b, res);
    106131                return res;
    107132        }
     
    137162        /*
    138163         * Return the other half to buddy system.
    139          */
     164         * PROBLEM!!!! FILL FIND OTHER PART AS BUDDY AND LINK TOGETHER
     165         */
     166        b->op->mark_busy(b, res);
    140167        buddy_system_free(b, hlp);
    141168       
     
    153180        link_t *buddy, *hlp;
    154181        __u8 i;
    155        
     182
    156183        /*
    157184         * Determine block's order.
     
    169196
    170197                        ASSERT(b->op->get_order(b, buddy) == i);
    171                
    172198                        /*
    173199                         * Remove buddy from the list of order i.
Note: See TracChangeset for help on using the changeset viewer.