Newsgroups: comp.os.minix
Subject: Re: dumb question: do you fork()?
References: <937lsp$dnl$1@nnrp2.phx.gblx.net>
Organization: Rochester Institute of Technology, Rochester, NY
From: aje9383@osfmail.isc.rit.edu (Andrew Erickson)
NNTP-Posting-Host: grace.isc.rit.edu
X-Original-NNTP-Posting-Host: grace.isc.rit.edu
Message-ID: <3a5a4629@news.isc.rit.edu>
Date: 8 Jan 2001 17:58:49 -0500
X-Trace: 8 Jan 2001 17:58:49 -0500, grace.isc.rit.edu
Lines: 44
XPident: aje9383
X-Original-NNTP-Posting-Host: 129.21.4.100
XPident: Unknown
Path: news.adfa.edu.au!clarion.carno.net.au!news0.optus.net.au!news1.optus.net.au!optus!news.mel.connect.com.au!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!logbridge.uoregon.edu!news.acsu.buffalo.edu!bingnews.binghamton.edu!news-nysernet-16.sprintlink.net!news.sprintlink.net!news.isc.rit.edu!aje9383
Xref: news.adfa.edu.au comp.os.minix:36474

[alt.os.development dropped, as my news server claims it's invalid and my
newsreader therefore won't let me post without dropping it.]

In article <937lsp$dnl$1@nnrp2.phx.gblx.net>,
John Jensen  <jjens@primenet.com> wrote:

<snip>

>What is the group's opinion on fork() as a processs creation mechanism.
>Is it adopted by UNIX-like OSes (MINIX) because that's the way UNIX does
>things ... or does fork() have performance advantages over some possible
>new_process()?  I've skipped around in the MINIX book, but haven't found a
>place where fork() is compared to alternatives.

Like most of the others who have responded, I tend to prefer a spawn() idea
to a fork() idea.  A few reasons:

o As has been hashed and rehashed already, it (can be) a little more
efficient in the common case.  In many cases, actual implementations of
fork() (e.g. UNIX systems) are somewhat quicker than other systems, but
that's mostly because (a) UNIX creates and destroys processes with great
abandon, so it's vital to have a quick fork(), whereas most other systems
tend to be more moderate; and (b) many operating systems associate far more
with a process than UNIX--things like windows, terminals, command lines,
etc.  A process is often more along the lines of a session than a UNIX
process.  (Yes, these are generalizations)

o fork() requires a greater degree of hardware support than spawn(); in
particular, for fork() to have reasonable performance, it must have some
small form of virtual memory support--different areas of memory need to
appear at the same address in different processes.  Virtually all desktop
computers these days support virtual memory; many embedded systems don't,
and many older systems didn't well.  (Minix for the M68000, which doesn't
necessarily have virtual memory support, uses a horribly inefficient
technique they call shadowing to get fork() semantics.  The entire data and
stack area of the child and parent are copied in memory on every process
switch; even with very carefully optimized copy routines, it's painful.)

I think fork() is a bit better for creating threads than processes, but even
there difficulties (or inefficies) arise over the various stacks of the
various threads.

-- 
Andrew Erickson
