> 
>  
> : The parent process's data segment is not copied, just re-alloced, and
> : rather than returning to the parrent process, fork sleeps on the parents
> : child_wait wait queue.
> 
>       Let me try to remind myself of the vfork semantics....  Basically,
> rather than copying the data segment on real computers the OS sets
> the data segment page tables to copy-on-write, so that the data segment
> copy time and space is saved, since it's all going to be replaced by the
> following exec, right?

No, that's what fork() does on modern machines.  vfork() was developed back
in the days when fork() actually did do a fully copy of the data segment,
the way it's done in elks.  This is a waste when you're forking for the
purpose of calling exec and waiting until the child exits.  From the (SunOS 4)
man page:

                                                 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.


which basically means that the parent gets suspended, the child uses
the parent's data segment until the execve() call at which point a new data
segment is allocated for the child process and the parent is allowed to
resume.

Eric

Reply via email to