jeudi 26 février 2015

Multiple mappings for a physical page



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:



  1. 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.

  2. 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.

  3. 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).

  4. 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