[comp.sys.mips] test-and-set

wje@redwood.mips.com (William J. Earl) (01/24/91)

In article <1991Jan22.163208.17618@cbnewsl.att.com>, rand@cbnewsl (m.randall.macblane) writes:
> I need help finding a test-and-set assembly language algorithm for the
> MIPS 3000 series. There is no assembly language test-and-set for the
> 3000 series but an algorithm apparently exists that uses the load and store
> instructions somehow. 

      In the MIPS II instruction set (R6000 CPUs), there are LL and SC
(load locked and store conditional) instructions which may be used to
implement a test-and-set routine.  In the MIPS I instruction set (all
CPUs), there are no such instructions.  For code which is to run on
all MIPS CPUs, we generally recommend the use of Lamport's algorithm,
although it does require knowledge of the maximum number of
participants.  The count of participants may be controlled by some
other lock, such as a UNIX semaphore or a server process.  The best approach
is to write a lock subroutine which resorts to Lamport's algorithm on
R3000's and uses LL/SC on R6000's; this produces the highest performance
on R6000's, while still being portable to all CPUs.

      Note that some R3000-based systems, such as SGI multiprocessor
systems, incorporate memory-mapped hardware lock objects.
-- 
	William J. Earl			wje@mips.com
	MIPS Computer Systems		408-524-8172
	930 Arques Avenue, M/S 1-03	FAX 408-524-8401
	Sunnyvale, CA 94086-3650