On Thu, 2011-04-21 at 10:59 +0200, François Goichon wrote: > Hello everyone, > > I have a question about the space creation flags provided to the > thread_control syscall. I need to spawn isolated threads and saw that > codezero's libl4 does not provide support for flags other than the > TC_SHARE_SPACE. > > What I actually am trying to reproduce would be the equivalent of a fork > system call (I just want to also provide an entry point but that's not > where the difficulty lies). My main problem is that TC_COPY_SPACE seems > to only copy the actual PTE entries into new PMD's. Therefore, the newly > created thread works on a different address space but actually on the > same physical memory. Would the simplest way be to use TC_NEW_SPACE and > then remap/copy all pages from the original space to the new one or is > there a practical way of doing it that I am missing? What is the point > of TC_COPY_SPACE if the resulting spaces work on the same physical pages > at the beginning? > > Thank you for taking the time to read this and don't hesitate to point > out any misunderstanding from my part. > > Best regards, > > François >
Francois, Are you using the v0.3 microkernel? You should use NEW_SPACE to build a new space from scratch (e.g. clear page tables). COPY_SPACE like you mentioned copies the existing page tables to the new process. If you would like to build fork-like functionality, there are two ways of doing it. You may create a new space and remap all pages like you mentioned. The way we did in mm0 was using COPY_SPACE though. FYI MM0 is a partial posix server, i.e. like a partial kernel running on top of the hypervisor. If you check this file: http://git.l4dev.org/codezero.git/blob/refs/heads/devel:/conts/posix/mm0/mm/clone.c sys_fork call, you will see that we first make some pages read-only on the parent before making the space copy. (vm_freeze_shadows) This way copy-on-write works for both parent and child after the copy space call. Feel free to check the sys_execve call as well, to get an idea on how fork + execve works. Both should be in working state as of v0.3. Thanks, Bahadir _______________________________________________ codezero-devel mailing list codezero-devel@lists.l4dev.org http://lists.l4dev.org/mailman/listinfo/codezero-devel_lists.l4dev.org