[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vfork()
On Mon, 3 Feb 2003 09:18:55 +0530
"Rupa" <rupa.ramakrishna@ionidea.com> wrote:
>
> Hello,
> I have a small doubt regarding the working of vfork() system
> call. when a call to vfork() is made, the child process created will
> be sharing the address space of the parent. I want to know whether
> the pid returned by the vfork() is same as the pid of
> parent. Because in case of fork() system call, child process differs
> from the parent by pid. I want to know regarding pid in case of
> vfork() system call.
You have to know that vfork() is really similar to fork() syscall and
so , just like fork(), child PID is different from parent's one. The
only difference is that they share the same address space. Infact
vfork() was created few years ago thinking about the scenario of a
process which has to fork a new process and then 'substitute' address
space with execve(). While fork() infact created a copy of parent
address space in child, vfork() didn't do it. So when you wanted to
exec another process the best thing to do was vfork() + exec**().
Infact, copying an address space which will be soon substituted is
useless. Now situation is really different since modern OSs use
Copy-On-Write in forking a process. So at current time, vfork() is not
useful as it was in the past.
As regards CLONE_PID flag (I read it in another mail) it's used in a
very limited range of situations. For example, if kernel is running on
SMP you need an init process on every CPU and so in this case it's
useful to create them with CLONE_PID (so all init process will have
PID 1).
Regards,
Angelo Dell'Aera
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
- References:
- vfork()
- From: "Rupa" <rupa.ramakrishna@ionidea.com>