Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: bill@cafe.net (Kaz Kylheku)
Subject: Re: [++] Tight coding
Date: 1998/03/02	[thread overview]
Message-ID: <ELCK.1713$Jb.2716787@brie.direct.ca> (raw)
In-Reply-To: slrn6fk0pe.5t2.peter@eepjm.newcastle.edu.au


In article <slrn6fk0pe.5t2.peter@eepjm.newcastle.edu.au>,
Peter Moylan <peter@ee.newcastle.edu.au> wrote:
>One of my major gripes about C is the strong influence it's
>had on operating systems design.
>
>We have memory segmentation.  We've had it for years.  What
>we don't have are operating systems that make proper use
>of the segmentation hardware.
>
>It's true that the earliest attempts to introduce segmentation
>were killed off by considerations of hardware cost and speed.
>But those problems were solved some years ago, when the
>80286 first appeared.  Once you can get the segmentation
>hardware onto the processor chip, and have some space left over
>for decent-sized caches, you've got the technology to bring
>segmentation to the masses at an affordable cost.
>
>The catch is that you have all those C programmers demanding
>a "linear address space".  Why would anyone need a linear
>address space?  Answer: it's needed if you want to do dirty
>tricks with pointer arithmetic.  Never mind that those dirty
>tricks fell out of favour years ago.  The C standard says
>that they're legal, so any C compiler that doesn't support
>them is not standard-compliant.

That is false. The C standard says no such thing; but of course, to know
that you actually have to read it, hint hint. If you compare two pointers to
distinct objects for anything other than exact equality, the behavior is
undefined.  Furthermore, if you use pointer arithmetic to produce a pointer
that would point outside of the boundaries of the object it was derived from,
the behavior is undefined. The only exception is that a pointer one element
past the end of an array may be safely produced.  

The reason operating system designers tend to eschew segmentation is that it
would make the operating system too dependent on one particular hardware (or
at least its central memory-management core). Not all processors support
the concept of segmentation in their memory management infrastructure.

When Linux was ported away from the x86 architecture, one of its aspects
that had to be abstracted was its use of segmentation. And Linux only
uses segmentation in an extremely basic way; the user data is in a
separate segment whose selector is loaded into the 'FS' segment register,
so that copying memory from user space to kernel space and vice versa
involves two segments. Luckily, Linux used fairly abstract functions to do
this, even though the 'FS' crept into their nomenclature.  Nevertheless,
even this basic use of segmentation hardware created portability
considerations. Fuill blown segmentation use could be a nightmare.  



  parent reply	other threads:[~1998-03-02  5:00 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-23  5:00 Wildfire and NT Robert Harley
1998-02-24  5:00 ` brianh
1998-02-24  5:00   ` Sean Burke
1998-02-25  5:00     ` brianh
1998-02-25  5:00     ` Mike Albaugh
1998-02-25  5:00     ` [++] Tight coding (Was: Re: Wildfire and NT) Terje Mathisen
1998-02-28  5:00       ` Piercarlo Grandi
1998-03-01  5:00       ` [++] Tight coding Bill Moyer
1998-03-01  5:00         ` Larry Kilgallen
1998-03-01  5:00           ` [++] Tight coding (comp.sys.dec-only thread) Bill Moyer
1998-03-01  5:00         ` [++] Tight coding Ruud Bruijnesteijn
1998-03-01  5:00           ` scott
1998-03-02  5:00             ` Kaz Kylheku
1998-03-02  5:00             ` Terry Moore
1998-03-02  5:00               ` Kaz Kylheku
1998-03-02  5:00               ` Pete Becker
1998-03-03  5:00                 ` Ruud Bruijnesteijn
1998-03-03  5:00                   ` Pete Becker
1998-03-04  5:00                     ` Terry Moore
1998-03-03  5:00                       ` Pete Becker
1998-03-04  5:00                       ` Ruud Bruijnesteijn
1998-03-02  5:00             ` Martin Tom Brown
1998-03-02  5:00         ` Peter Moylan
1998-03-02  5:00           ` Scott Fluhrer
1998-03-02  5:00           ` Lawrence Kirby
1998-03-02  5:00             ` Peter Moylan
1998-03-02  5:00               ` Ketil Z Malde
1998-03-04  5:00                 ` Lyn A Headley
1998-03-02  5:00               ` Kaz Kylheku
1998-03-03  5:00               ` Lawrence Kirby
1998-03-02  5:00           ` Kaz Kylheku [this message]
1998-03-02  5:00           ` Martin Harvey
1998-03-03  5:00           ` Larry Kilgallen
1998-02-25  5:00     ` Wildfire and NT Maynard Handley
1998-02-24  5:00   ` Bill Moyer
1998-02-25  5:00     ` Larry Kilgallen
1998-02-25  5:00       ` brianh
1998-02-25  5:00         ` Epiphanies (was: Wildfire and NT) Carlie Coats
1998-02-25  5:00     ` Wildfire and NT John Hascall
1998-02-25  5:00       ` Rob Rodgers
1998-02-24  5:00   ` David Hinds
1998-02-25  5:00     ` Del Cecchi
1998-02-25  5:00     ` brianh
1998-02-25  5:00   ` Bernd Paysan
1998-02-25  5:00     ` brianh
1998-02-26  5:00       ` Bernd Paysan
1998-02-27  5:00         ` brianh
1998-03-01  5:00           ` Ketil Z Malde
1998-02-26  5:00       ` Doug
1998-02-26  5:00         ` Jeffrey S. Dutky
1998-02-27  5:00   ` Paul Kahler
1998-03-02  5:00     ` Joel Gallun
1998-03-02  5:00       ` Przemek Klosowski
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox