This describes the hardware and software overhead of forming and consulting a snapshot of 230 bytes of memory on an x86 computer system assuming several CPUs sharing many gigabytes of DRAM. The program that creates the data structure to be shared this way should place that structure at a virtual address which is a multiple of 230. This is not an onerous restriction on machines with a 248 bit address spaces. We assume that this memory is not initially shared. On a x86 this memory will be mapped with a two level memory map consisting of one page M of pointers to 512 pages Mj of pointers to 5122 pages that hold the data. These mapping pages are in kernel memory and are brought into existence only as the data pages they refer to are populated.

The kernel is initially ignorant of the plan to share. When a snapshot is requested by P whose address space contains the segment S the kernel changes a bit in a memory map that belongs to P and locates M to indicate that P may no longer store into S. At this point the TLB must be purged, perhaps selectively, depending on hardware features. There is a deferred cost here in reloading the TLB. Attempted writes to S by P cause P to fault leaving S unmodified.


then the cache where P is running must be flushed, again perhaps selectively.

A RO pointer to M may now be placed in a mapping table of some other program. That pointer will also indicate that stores are to produce faults. The new program will immediately be able to read the data in S at only the cost of loading TLB entries. The two programs now have symmetric RO access to the data.

At this point either program may attempt to store into the shared segment. Either program will suffer a fault the first time it tries to store into a page. Upon the first such store the kernel will consider whether the faulting program has the authority to modify S. This was a snapshot and thus neither store must be seen by the other program, as in the Unix fork. If policy allows the store then the kernel must first allocate a new page frame for a duplicate M' of M. The entries in M' are all RO however and the entries M are modifies to RO. The locator of M in the new space is supplanted by a RW locator to M'. Let j be bits 21 thru 29 inclusive of the fault address. Entry j in M' locates a page table, M'j that must also be duplicated in a new page frame. The entries in M'j are all set to RO however. Entry j in M' is replaced by a pointer to the copy of M'j. That pointer is marked RW. Let k be bits 12 thru 21. Entry k of M'j locates a page of data that must be duplicated to allow the store. Entry k of M'j is replaced by a pointer to the new page. That pointer is marked RW. The faulting program can be restarted and the store will succeed.

Three pages have been allocated and the modified segment and snapshot are still available and mapped. The only writable pages in the two segments are the page where they differ due to the store.

All of this is dramatically cheaper than copying all of S, both in time and space.