On Tuesday, 21 May 2013 at 20:08:16 UTC, Leandro Lucarella wrote:
I'm interested in what you're describing, but I don't know how
can you
achieve this without fork()ing (or clone()ing in Linux). What
does
"remap shared memory using COW" in a context where fork()
doesn't
happen? Why do you even need shared memory if fork() doesn't
happen? If
"remap shared memory using COW" means get a different address
for the
same block of memory until a write happens in that block, then
you can't
scan the roots anymore.
I'm *very* interested in your suggestion.
I do mean mapping the same physical block of memory into two
virtual memory blocks, such that a write will cause the OS to
make a copy and sever the link.
Given that we're dealing with significantly large blocks of
memory all in multiples of the page size, it should be a simple
matter to map from one copy of the memory to the other and back
again using basic pointer arithmetic, so scanning the roots
should not be a problem.
You need shared memory because a file handle is needed when
calling "mmap" to enable the COW functionality, and shared memory
lets you get a file handle to a block of memory.