exec* exiting?

Mats Wichmann mats at laplaza.org
Mon Aug 20 21:13:47 EDT 2001


On Mon, 20 Aug 2001 10:12:20 +0200, "Alex Martelli"
<aleaxit at yahoo.com> wrote:

:"Neil Macneale" <mac4-devnull at theory.org> wrote in message
:news:3b80743c$0$319$8eec23a at newsreader.tycho.net...
:    ...
:> It turns out that its has been awhile since I used the exec* functions
:> in C, and now I remember why- I don't like fork()! I consider it black
:> magic.  Forking from a process which uses a lot of memory is not
:> something I want to do all the time.  Especially considering the program
:> I am writing.
:
:On good Unix-ish implementations, your process's memory is
:only duplicated 'virtually', with copy-on-write.  It's therefore
:no big issue to fork "a process which uses a lot of memory".
:It's not Unix V7 on a PDP-11 any more, you know -- we have
:virtual memory these days, and page tables, and other such
:modern wonders.

Yup, it's really only some page table fiddling.  "Text" (code) is
shareable anyway since it's put in a read-only segment. Page table
entries for data are marked copy-on-write.  If the very next thing you
do is "exec" the cost is not terribly high.

The earlier BSD solution was to write a version of fork (vfork) that
declared your intention to immediately perform an exec so the kernel
didn't have to do the work of setting up those things that would be
tossed.

Mats Wichmann

(Anti-spam stuff: to reply remove the "xyz" from the
address xyzmats at laplaza.org. Not that it helps much...)



More information about the Python-list mailing list