Suggestions About Memory Allocators
Posted: Wed Mar 31, 2010 9:49 pm
I was thinking about implementing a good memory manager for my OS project and I thought of several possibilities. The first was related to paging. In my OS project, reserve the first 1GB of memory to the kernel, and the rest for the user programs.
If each program has its own address space, so I conclude it would be interesting to allocate all the kernel Page Tables (for 1GB, 256 PTs would be used). Thus, 1 MB of memory is used, but has the advantage that when I was a new process, just copy the kernel page tables for pages tables of the processes, then all these pages mapped on kernel page tables would be available instantaneously.
Or I could go by placing the page tables when necessary, but there would be a serious problem if I change the page directory (in my OS, each process has its own page directory). With this, if I carry a module or anything else once I've uploaded a process, I would have to remap the page tables of all processes loaded.
Which of the options would be better? Or is there something else?
Another thing is with respect to the algorithm to allocate / deallocate memory for the kernel and modules. I'm using double linked list heap algorithm to allocate / deallocate memory for the kernel. As I understand it, the heap algorithm seems "somewhat slow." The first thing I did to improve the heap algorithm was to remove it the page aligned allocation. Instead I created a bitmap containing all the pages in use (a bitmap for stack modules and kernel threads, another bitmap for processes's PTs and PDs, and so on). All these structures are stored in the kernel heap.
There are so many possibilities that I am very confused on who to use. Suggestions will be helpful.
If each program has its own address space, so I conclude it would be interesting to allocate all the kernel Page Tables (for 1GB, 256 PTs would be used). Thus, 1 MB of memory is used, but has the advantage that when I was a new process, just copy the kernel page tables for pages tables of the processes, then all these pages mapped on kernel page tables would be available instantaneously.
Or I could go by placing the page tables when necessary, but there would be a serious problem if I change the page directory (in my OS, each process has its own page directory). With this, if I carry a module or anything else once I've uploaded a process, I would have to remap the page tables of all processes loaded.
Which of the options would be better? Or is there something else?
Another thing is with respect to the algorithm to allocate / deallocate memory for the kernel and modules. I'm using double linked list heap algorithm to allocate / deallocate memory for the kernel. As I understand it, the heap algorithm seems "somewhat slow." The first thing I did to improve the heap algorithm was to remove it the page aligned allocation. Instead I created a bitmap containing all the pages in use (a bitmap for stack modules and kernel threads, another bitmap for processes's PTs and PDs, and so on). All these structures are stored in the kernel heap.
There are so many possibilities that I am very confused on who to use. Suggestions will be helpful.