Subject: Re: PROPOSAL: removal of brk()/sbrk().
To: Simon Burge <simonb@wasabisystems.com>
From: Robert Elz <kre@munnari.OZ.AU>
List: tech-kern
Date: 02/28/2002 02:41:54
    Date:        Tue, 26 Feb 2002 22:40:15 +1100
    From:        Simon Burge <simonb@wasabisystems.com>
    Message-ID:  <20020226114016.186E71E4FE@thoreau.thistledown.com.au>

  | The original Bourne shell does this.  I don't know if the reason was that
  | it pre-dated malloc(3) or was meant to be as lean as possible.

It certainly didn't pre-date malloc (or its earlier equivalents).
The (original) Bourne shell used this method as it avoided any need
to handle explicit memory management - just use RAM, and it appears
under you.   Which is kind of nice, but horribly non-portable.

The pain needed to make this work on a system that wasn't able to restart
instructions that faulted because of an invalid address error can only
barely be imagined -- the quick and dirty was to sprinkle around dummy
references to memory beyond what the shell was likely to need to reference
any time soon (it tended to only allocate in small chunks) and so not care
that the failing reference would be aborted, and not restarted ...

And no, it isn't required that architectures support restart of invalid
address references - they need to support restart of unmapped address
references (for paging), and often it is easy enough to do both using the
same mechanisms so it happens to work, but not providing restart state (or
instruction backup) for an invalid address (which is really just a
programming bug) is a perfectly valid architectural choice.

kre