Subject: Re: Compiling postgresql on pmax
To: Jon Buller <jon@bullers.net>
From: Simon Burge <simonb@wasabisystems.com>
List: port-pmax
Date: 03/08/2001 10:26:55
Jon Buller wrote:

> Uwe Lienig <Uwe.Lienig@fif.mw.htw-dresden.de> wrote:
> 
> > What about
> > getting postgresql running on pmax under 1.5 ?
> 
> Well, the short answer is: TAS stands for Test And Set.  It needs
> to be an atomic instruction in the hardware.  It is obviously not
> implemented currently in PostgreSQL at the moment.  I do not know
> if the pmax has the required hardware to do it. (I personally know
> that Sparc's, PC532's, and m68k's do, and that there are others,
> but I haven't dealt with them directly.)
> 
> I wrote this little piece of code for the PC532 some time ago, and
> I'd be happy to do it for the pmax as well, provided I knew any
> MIPS assembly and the MIPS processor had the hardware support. I
> have hearsay evidence that MIPS does not have the hardware to do
> this.  If that is true, it does not mean that the pmax will never
> run PostgreSQL, just that it may never run it well, or quickly, if
> someone goes to the trouble of fixing it.

The problem is that older CPUs (the r2000/r3000's) don't have the
load-linked and store-conditional instructions that make up a
test-and-set type operation (and indeed some of the MIPS-III CPUs
used by some hpcmips models don't either(!)).  There's four workable
solutions that I know of (in increasing order of difficulty):

 a) Ignore the older processers and use the LL/SC instructions.
 b) Use semaphores.  At least older versions of postgres could
    be configured to do this.  I'm not 100% sure if this is true
    any more.
 c) Implement a test-and-set style syscall.  Ultrix had the
    atomic_op syscall.
 d) Implement something called "Fast Mutual Exclusion for
    Uniprocessors", ref
 http://www.cs.cmu.edu/afs/cs/project/mach/public/www/doc/abstracts/Rcs.html
    This looks cool, but I don't plan on doing anything like
    that soon.

I'm tempted to do something like the atomic_op syscall (called through
the sysarch mechanism), at least for MIPS (I don't know what other CPUs
are missing TAS primatives).  The reason I'm leaning this way is that we
can use this to also implement the atomic_op Ultrix-compat syscall.

> Anyway, if someone can point me to a good assembly language reference
> for the pmax, I'll see if I can code something up.  (Or see if it
> is possible to code something up.)

For reference, the IRIX TAS code in postgresql uses LL/SC.

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD CDs, Support and Service:    http://www.wasabisystems.com/