I want to create a copy-on-write like interface for accessing a mmap()ed file in GNU C. Here is the way it should work:
- I will map the file to the address space using
mmap(). Doing so, I will have a pointer to a contiguous region of memory which will contain real data. - Using some sort of magic, I will have another part of the address space pointing to the exact same physical pages. In other words, I will have two different addresses to access any physical page on memory for the
mmap()ed region. - Once an instruction tries to write to a page using the second mapping, I will change the mapping for that particular page to point to a different physical page (which I will create in a on-demand fashion).
- At some point, I will sync the dirty-page with originally mapped page and change the alias to point to the memory-mapped page.
Here is the question: What is the best way to do this?
Aucun commentaire:
Enregistrer un commentaire