Is my understanding of memory management correct?
Posted: Wed Jun 06, 2012 11:50 am
I already have paging switched on and working before I jump into the C kernel. I have the first 4MB identity mapped, and I also have the 4MB starting at 2GB mapped to the physical first 4MB (in other words, 2 page tables pointing to the same physical space).
Now I plan to start writing the memory management stuff, and want to make sure I understand the theory behind it. From reading around, I'm starting to understand that there are (roughly) three levels of management that need to be done for applications to work.
Lastly, although I said that heap memory management is left to the applications, I take it that there is one application in particular where it is my responsibility: the kernel itself! Is this true?
Thanks for taking the time to read this, and apologies for cramming so many questions into my first post.
Now I plan to start writing the memory management stuff, and want to make sure I understand the theory behind it. From reading around, I'm starting to understand that there are (roughly) three levels of management that need to be done for applications to work.
- Physical memory manager. This allocates and frees physical memory in units of the page size (typically 4kB). It must keep track of memory that it has already allocated, and that that has been freed, and will at least include a function to allocate and one to free blocks of memory. The functionality it supplies will only ever be used by the virtual memory manager (the next "level").
- Virtual memory manager. This will use the physical memory manager to allocate/free physical frames in order to create and manage the page directory (of which there may be more than one) and the tables it contains. This also only works in units of 4kB (or whatever the page size is).
- Heap memory manager. This makes use of the virtual memory manager to grab free memory (of any size), creating new tables/directories if necessary, and clean up later. This is typically left to the applications themselves, and isn't done in the kernel (e.g. malloc(), new(), etc. in application code).
Lastly, although I said that heap memory management is left to the applications, I take it that there is one application in particular where it is my responsibility: the kernel itself! Is this true?
Thanks for taking the time to read this, and apologies for cramming so many questions into my first post.