> -----Original Message-----
> From: Gary R. Van Sickle [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 21, 2002 2:32 PM
> The thing is, a lot of work *has* been done to make fork as
> efficient as possible. But there's a limit on how fast you
> can create a new process and duplicate the current one into
> it. And Windows doesn't go out of its way to help.
Also worth considering is the implicit overhead (both with and without
optimisations such as copy-on-write) of duplicating a process and then
replacing the image vs creating a process from a image.
In reverse order, a) loading the image is the same in both cases:
library path searches, permission checks, prologue code, and then you
are in business. So however fast one of these is made, the other can
match.
b) A process really is just a bunch of kernel structures: memmory map +
page tables , environment block, permissions block, ownership,
threads... and actual virtual memory.
Duplicating a process requires (in general terms):
Copying all the kernel structures.
Fixing them up - adjust child relationship, pid etc.
Assign new virtual memory (may be same via cow) mapped to the original
address's in the process
Note that the amount of work is directly related to the size of the
process. Forking 4Gb of VM is always going to be more work that forking
20kb of VM.
Creating a process requires (in general terms):
Creating empty kernel structures with appropriate values.
Assign the first VM page.
Mapping the image in - fixup library requirements etc. (from a)).
So the unique aspect of creating a process is
Creating empty kernel structures with appropriate values.
Assign the first VM page.
To compare then, you have a near-constant 'trivial' new process overhead
(spawn) vs a variable overhead (but almost guaranteed to be greater
(that is barring corner cases)) than new process overhead (fork + exec).
Hmm, which seems more efficient?
Lol,
Rob
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/