Re: PATCH(?): linux-2.4.4-pre2: fork should run child first

From: Adam J. Richter (adam@yggdrasil.com)
Date: Fri Apr 13 2001 - 18:51:34 EST


"John Fremlin" <chief@bandits.org> writes:
> "Adam J. Richter" <adam@yggdrasil.com> writes:
>> Guess why you're seeing this email. That's right. Linux-2.4.3's
>> fork() does not run the child first.

>[...] If an app wants to fork and exec, it
>should use *vfork* and exec, which is a performance win across many
>OSs because the COW mappings don't even have to be set up, IIRC.

        Even in that case, you want to run the child first because
it may block on I/O when it does the exec or the new program starts
running, and you are likely to be able to use that time while the
child is waiting on I/O for the parent to run (typically just to
record the process in its internal data structures and then call
wait()). Basically, you want to kick off some new I/O before running
something that can run while that I/O is pending.

        Of course, in the vfork case, this change is probably only a
very small win. The real advantage is with regular fork() followed
by an exec, which happens quite a lot. For example, I do not see
vfork anywhere in the bash sources.

Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104
adam@yggdrasil.com \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 15 2001 - 21:00:22 EST