On Saturday, I implemented a basic physical memory manager. The was I have designed it (which is far from perfect and eventually I will redesign and rewrite this code) is like this:
I partitioned the memory in some sections. And each section is divided into small units. For example, section one is divided into units of 32 bytes, section two into 64 bytes and so on. There is a bitmap for each section that represents the units.
Whenever memory is allocated dynamically, the size is converted into the nearest unit size and first free unit is allocated. The corresponding bit in the corresponding bitmap is set to mark it used.
Currently I am not using virtual memory and handling physical memory only. Once I enable paging, I will manage the physical memory in terms of pages, ala Linux. Then I will design a slab allocator to create small objects and so on.
Next big item is multitasking. It is gonna be in RING0 and non-preemptive for now. I am going for the software multitasking rather than using TSS (because of the limit on number of tasks etc). Its gonna be FUN! :)