Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/17/84 chuqui version 1.7 9/23/84; site daisy.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!pyramid!nsc!daisy!david
From: david@daisy.UUCP (David Schachter)
Newsgroups: net.arch
Subject: Re: What I miss in micro-processors (fairly long)
Message-ID: <126@daisy.UUCP>
Date: Tue, 1-Oct-85 02:04:49 EDT
Article-I.D.: daisy.126
Posted: Tue Oct  1 02:04:49 1985
Date-Received: Thu, 3-Oct-85 04:33:41 EDT
References: <796@kuling.UUCP> <2580002@csd2.UUCP> <191@graffiti.UUCP> <568@unisoft.UUCP>
Reply-To: david@daisy.UUCP (David Schachter)
Organization: Daisy Systems Corp., Mountain View, Ca
Lines: 35


On our 80286-based workstation, we set the descriptor table
entry for segment #0 to be an invalid entry.  We force the
system memory manager to set memory to zero before passing
the requested block to the requestor.  Thus, uninitialized
pointers get selectors of 0.  When a reference is made via
one of these nasty points, the CPU traps with an "invalid
selector" trap.  Takes care of most of the bad pointer
problems.  For the remainder, we tell the memory manager to
fill memory with 0FAF4H instead of 0.  This pattern is
never a valid selector.  If used as an index into a table,
it will usually cause a segment overrun error unless the
table is of byte-wide quantities.  If executed, it halts
the CPU with interrupts enabled.
  
Of course, the 80286 traps stack overflow/underflow and
any other attempts to run off the end of segments.  Thus,
uninitialized variables, which were a big problem on the
8086, have ceased to be major time-wasters on the 80286.

By the way, forcing the system memory manager to fill
segments with a value before returning them to the requestor
costs << one percent in run time.
  
In addition, to further improve the ability to detect
uninitialized variables, we have conventions on what
constitutes invalid values.  Usually, 0FFH and 0FFFFH
are invalid values for bytes and words, by Daisy convention.
Programmers are "encouraged" to set all data area to these
values during program initialization and to check variables
for these values as consistency checks during program
runtime.
  
These techniques aren't cure-alls but they solve the
majority of the problem for us.