Bond, You might want to look at the example of malloc at the end of KnR. On Mon, Sep 27, 2010 at 11:05 PM, Bond <jamesbond.2k.g@xxxxxxxxx> wrote: > I have to write my own kmalloc. > I am not given any sort of Kernel API to assign or delete memory. > Suppose I have 4GB of memory on Ram. > Some of which is filled and some of which is not filled. > My question is what data structure do I need to maintain in order to be able > to assign memory > to any userspace program when the program requests some bytes of memory > which can be 1 or > more. > My logic for this implementation was to maintain a hashtable. > For example > 1------> points to all the memory addresses which are 1 byte and free > 2------> points to all the memory addresses which are 2 byte and free > 3------> points to all the memory addresses which are 3 byte and free > 4------> points to all the memory addresses which are 4 byte and free > . > . > . > . > . > . > . > n------> points to all the memory addresses which are n byte and free > How can I improve the above schema because to know the location where 1byte > memory is free > I will maintain a pointer which can be u64 or u32 which itself is costlier > than the free memory itself. > So what should I be doing to be able to do above. -- Thanks - Manish ================================== [$\*.^ -- I miss being one of them ================================== -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ