Subject: Re: Test and set (was Re: postgreSQL)
To: Simon Burge <>
From: Chris G. Demetriou <>
List: tech-kern
Date: 05/25/1999 22:56:34
Simon Burge <> writes:
> 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?

Yes, it would be a waste of a syscall.

This is best implemented without kernel interaction if possible,
because of the cost of of a syscall.  that's possible on several

On architectures where it has to be implemented as a sycall, the right
syscall already exists (sysarch()).

A standard API would be fine, good actually.

> 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 :-)

Alpha has "load ... locked" and "store ... conditional", which make it
possible to write mutex code in user-land, yes.

> 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?

really, on the mips, what you probably want is a library
routine/function pointer which on first run checks the cpu type and
replaces the function pointer either with one that invokes a the LL/SC
instructions or invokes the syscall.

Chris Demetriou - -
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.