vfork

vfork

shlomo bauer shlomobauer at gmail.com
Sat Jun 20 22:52:56 IDT 2009


fork vs. vfork

The issue is this:  the orginal paradigm was fork and exec -- someone,
a long time, ago, realized that if  the child does an exec to overlay
the copied process, then a fork would be quicker if the parent process
wasn't copied into the child process -- vfork.

Today, this is probably not the case for a variety of reasons --
notably copy on write semantics of memory; there is little reason to
copy the uproc space (or whatever linux calls it now) since it can be
copied on a write automatically.  My recollection on vfork is probably
around 1988 when i was working on real-time unix

Fork-exec is a commonly used technique in Unix whereby an executing
process spawns a new program. fork() is the name of the system call
that the parent process uses to "divide" itself ("fork") into two
identical processes. After calling fork(), the created child process
is actually an exact copy of the parent - which would probably be of
limited use - so it replaces itself with another process using the
system call exec().

vfork is called if exec is called shortly afterwards -- vfork does no
copying, instead the parent process "loans" its address space to the
child and blocks until the child returns it.  The
child continues using the parents address space until it executes and
exec (many variants)
or exit (_exit).

Have fun.
Shlomo



More information about the Linux-il mailing list