On Wed, Dec 15, 2010 at 3:33 PM, Dave Hylands <[email protected]> wrote:
> Hi guys,
>
> On Wed, Dec 15, 2010 at 10:50 AM, Enrico Granata <[email protected]> wrote:
>> I believe his question actually sounds like: why does Linux need two system
>> calls to start running a new program? Wouldn't it be simpler to do this the
>> way Win32 does it: a CreateProcess() system call that actually loads a NEW
>> program in NEW process?
>
> So fork is actually the heavyweight variant. It copies the page tables
> of the calling process.
>
> If you know that the fork will be followed by an exec, then you're
> better off to use the lightweight version of fork, called vfork, which
> does not copy the page tables of the calling process.
>
> Also keep in mind that it's perfectly legal to call fork without calling exec.
>
> And, fork and vfork are really just front-ends for clone which is the
> function that deals with all of the variants...
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.DaveHylands.com/
Thanks Dave,
So
==
if (vfork())
execve(...)
==
would be ultra-lightweight at the fork level because not even the page
tables would be copied. I didn't know that. Seems extremely useful
for huge programs that need to spin-off a little task.
Always something new to learn.
Greg
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ