9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Digby Tarvin digbyt@acm.org
Subject: [9fans] spawn() vs fork()
Date: Sat,  3 Jul 1999 16:22:21 +0100	[thread overview]
Message-ID: <19990703152221.qcf4sgrSd3VPYTezP39jPzCwOMbviZEUE8wWyA-Toug@z> (raw)

>
>Imagine how you would do IO redirection with spawn().
>
I don't have to imagine - I have done a lot of work with the OS-9
operating sytem which does just that.

OS-9 dates back to the time when memory management with dynamic
address translation was pretty rare and exotic (originally ran
on M6809) so for maximum hardware portability the system
assumes that everything works on physical addresses.
MMU, if available, is only used to restrict read/write access.

That compromise meant that a fork() style of process creation
was not possible (all pointers in the child's data segment would
be pointing into the parents memory), so it uses a spawn() style
of process creation.

I/O redirection is implemented using a flurry of dup(), close() open()
calls before and after the child is created (combined with the ability
to control how many open file descriptors are passed on to the child).

Fork() is a much more elegant way of giving code in the parent
process a chance to initialise the environment for the child
before transferring control - not only I/O, but also current
directory, UID, priority etc, all without having to define a
set of additional system calls or adding a long list of arguments
to the spawn request...

On the down side, appart from relying on address translation, fork()
is usually more complex to implement in the kernel, and a
fork()/exec() sequence usually involves more run time overhead
than a single combined semantic.

Regards,
DigbyT
--
Digby R. S. Tarvin                                              digbyt@acm.org
http://www.cthulhu.dircon.co.uk




             reply	other threads:[~1999-07-03 15:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-03 15:22 Digby [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-07-05 13:23 Digby
1999-07-05  9:09 rog
1999-07-05  7:57 steve.kilbane
1999-07-03 10:23 Jean
1999-07-03  9:53 Guan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990703152221.qcf4sgrSd3VPYTezP39jPzCwOMbviZEUE8wWyA-Toug@z \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).