[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pvfork()



Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>:

> I have just recetly learned that vfork() is supposed to block even
> under "real" Unix (if it's available at all).  So there is no real
> need for a non-blocking Pvfork() since no Unix code depends on it :-)

Nicholas S Castellano <entropy@terminator.rs.itd.umich.edu>:

> Indeed you are correct!  I didn't know that either, but APUE does say
> that it blocks.  Sigh...I was hoping to avoid the need for kludges
> like __fork_and_exit(), by simply using vfork() instead of fork().

Yes, U*ix always has fork() but not neccessarily vfork().  vfork() is
a bit of a kludge on systems that don't have efficient copy-on-write
for pages in the process memory.  On PC Linux vfork() is a just
synonym for fork().

>From the SunOs man page:

     vfork() can be used to create new  processes  without  fully
     copying  the  address  space  of  the  old process, which is
     horrendously inefficient in a paged environment.  It is use-
     ful  when the purpose of fork(2V), would have been to create
     a new system context for  an  execve(2V).   vfork()  differs
     from  fork()  in  that the child borrows the parent's memory
     and thread of control until a call to execve(2V), or an exit
     (either  by  a  call  to exit(2V) or abnormally.) The parent
     process is suspended while the child is using its resources.

     [...]

     This system call will be eliminated  in  a  future  release.
     System implementation changes are making the efficiency gain
     of vfork() over fork(2V) smaller.  The memory sharing seman-
     tics of vfork() can be obtained through other mechanisms.

							
Urs