Subject: Test and set (was Re: postgreSQL)
To: None <port-pmax@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: tech-kern
Date: 05/26/1999 15:40:58
[[ To tech-kern as well - some general issues ]]

Lord Isildur wrote:

> not much help, but i have successfully built whatever was the most recent
> version of postgres last october under Ultrix... where is postgres failing? 

I went looking at this, and found that Ultrix uses SysV semaphores (and
notes that it takes a 40% performance hit for doing this - but I don't
know relative to what).  Ultrix has a man page for the atomic_op(2)
system call that would seem to be a better solution (for Ultrix).
NetBSD doesn't have anything like this - would it be a waste of a system
call (or a possibly system-call backed library routine) to add some sort
of MI atomic test and set operation?  Here's some snippets from Ultrix'
atomic_op(2):

	Name
	       atomic_op - perform test and set operation.

	Syntax
	       #include <sys/lock.h>

	       int atomic_op(op, addr)
	       int op;
	       int *addr;

	...

	Description
               The call provides test and set operation at a user
               address.

               For RISC systems, is executed as a system call.  For VAX
               systems, a system call is not executed for this library
               function.

	Return Values
               If the atomic_op operation succeeds, then 0 is returned.
               Otherwise a -1 is returned, and a more specific error
               code is stored in errno.

DEC UNIX (pick a name today!) provides this for backwards compatibility.
I guess it must be a library routine there, Chris hasn't implemented it
in the recent OSF compat stuff :-)

The R4000 and later MIPS processors (actually MIPS II CPUs and later)
have the LL (Load Linked) and SC (Store Conditional) instructions, but
this really doesn't help everyone :-(  Are there any other archs other
than MIPS that don't have a test and set available to user code?

Simon.