Generalized virtual memory management
Posted: Thu May 25, 2006 11:01 pm
Hi!
In the last time, I have made up my mind about how I'm going to handle virtual memory mappings in my os, and I've come up with some design thoughts that I wanted to share with you and open for comments, critics, suggestions and flames. ;D
The basic idea is to group certain pages of physical memory together to form a 'memory section'. A memory section provides an abstract view into memory, it has a specific length (which is a number of pages) and each of its pages is mapped either to physical memory, or to a page of another section. In the latter case, this can form a 'mapping hierarchy' (multiple sections are stacked on top of each other then).
To improve coherence of design, I thought that all physical memory should be represented by a special memory section, so when you map a page of physical memory, it works the same way as mapping a page of another section. Furthermore, the virtual address space itself should also be represented as a special section of its own. As soon as you map some page into it, it will be entered into the processor's page tables and be accessible through linear memory.
So that's the basic idea. I think with this design it should be easy to implement things like shared memory, swapping, COW and memory mapped files (these are all things that could be represented by memory sections then). I'm not yet sure about implementation details however, especially which data structures to use for keeping all the mapping data. I'm afraid that the memory overhead will get larger than I thought at first. :\
So what do you think? I'm curios whether someone of you has thought of a similar design, and how did you implement it? Comments and critics welcome. If you are interested in more details, let me know.
cheers Joe
In the last time, I have made up my mind about how I'm going to handle virtual memory mappings in my os, and I've come up with some design thoughts that I wanted to share with you and open for comments, critics, suggestions and flames. ;D
The basic idea is to group certain pages of physical memory together to form a 'memory section'. A memory section provides an abstract view into memory, it has a specific length (which is a number of pages) and each of its pages is mapped either to physical memory, or to a page of another section. In the latter case, this can form a 'mapping hierarchy' (multiple sections are stacked on top of each other then).
To improve coherence of design, I thought that all physical memory should be represented by a special memory section, so when you map a page of physical memory, it works the same way as mapping a page of another section. Furthermore, the virtual address space itself should also be represented as a special section of its own. As soon as you map some page into it, it will be entered into the processor's page tables and be accessible through linear memory.
So that's the basic idea. I think with this design it should be easy to implement things like shared memory, swapping, COW and memory mapped files (these are all things that could be represented by memory sections then). I'm not yet sure about implementation details however, especially which data structures to use for keeping all the mapping data. I'm afraid that the memory overhead will get larger than I thought at first. :\
So what do you think? I'm curios whether someone of you has thought of a similar design, and how did you implement it? Comments and critics welcome. If you are interested in more details, let me know.
cheers Joe