[uClinux-dev] Question about fork and vfork
dhowells at redhat.com
Wed Aug 3 17:39:41 EDT 2005
edward_shao at wistron.com.tw wrote:
> However I'm wonder why MMU-less CPU can not support truly fork().
> What is the reason ?? (copy-on-write??) :p
Imagine you fork off one process from the other. Both processes will then
expect to find the bits of data they already knew about at the same addresses,
and will expect to find their stacks in the same locations. Without an MMU to
bend the addresses, they will then end up stamping on one another's data. You
_could_ write your application to take account of this, but then you may as
well use clone() and tell it to share the VM - effectively do multithreading.
It _is_ possible to implement fork() on an MMU-less system, provided you're
willing to accept the overhead of moving large chunks of data around such that
the process that's about to run sees all of the bits it's expecting at the
right addresses and uncorrupted by some other process; whilst the overlapping
bits of the outgoing processes are safely ensconced elsewhere beforehand. Now
imagine doing this on an SMP MMU-less system...
More information about the uClinux-dev