[net.arch] "yellow" and "red" zones in the stack

gnu@hoptoad.UUCP (04/22/86)

In article <576@mtxinu.UUCP>, ed@mtxinu.UUCP (Ed Gould) writes:
> >What is a "red and green" stack violation?  I've heard references to this
> >over the years, but no one has given me a satisfying explanation.
> In some models of the PDP-11 - definitely the 11/70, maybe the /45,
> and I don't know about the newer ones - there are registers in the
> MMU that...			 ...will cause a trap when the
> stack pointer is less than the value in the register.  One such
> register specifies what is called the "yellow zone," indicating
> a recoverable error, the other specifies the "red zone," an unrecoverable
> error.

I saw a reference to this years ago in a paper Microsoft wrote to guide
the turkeys who were coming to them with hardware and saying "Port
Xenix to this please".  The idea is that a reference in the yellow zone
will cause an interrupt, which is recoverable and warns the kernel to
allocate more stack space.  If you hit the red zone, you are out of
bounds and get an unrecoverable trap.  The kernel can slide the
yellow and red zones up and down to manage user processes' stack space.

In Microsoft's case, this was necessary because there is no recoverable
bus error on the 8086, 68000, etc.  People found that on the 68000 they
could include a "stack probe" instruction whose behaviour was well
enough known that a bus error in it could be recovered from.  (For the
Mac, Apple also explored the behaviour of procedure calls and figured
out how to restart them.) But general case instructions could not be
recovered from until the 68010.  I don't think this was solved in the
x86 family until the 80386.
-- 
John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   jgilmore@lll-crg.arpa
			     Post no bills.