[comp.arch] cas for VAX

swfc@cs.columbia.edu (Shu-Wie F Chen) (09/29/90)

I am porting some Concurrency Control code for Sun-3s (68020-based)
over to a uVax 3600.  Since CC needs atomic instructions, the original
implementors wrote a C interface to the 020 cas and cas2 instructions
and used cas to implement atomic increment, atomic queue insertion,
and binary P/V (no comments on efficiency please, at least not yet).
I have two choices:

1. write a C-interface cas for the Vax which does not have a cas
instruction

2. write atomic increment using the Vaxen INCL instruction, use
Ultrix's semaphore packages, and somehow write the atomic queue
insertion.

The problem is that I don't know Vax assembly well enough to know how
to write cas (I do know enough to have written inc based on INCL) nor
do I know enough to be able to write the atomic queue insertion.

If you have any solutions or ideas, please send e-mail.  Any
suggestions on efficiency are also welcome.

I've included the original implementation of ins and P for reference.

ins(p,n)
struct node *p, *n;
{
	struct node *new, *old;

	do {
		old = p->next;
		n->next = old;
	} while (cas(old, new, &p->next));
}

P(sem)
bsem *sem;
{
	do
	;
	while(cas(GREEN, RED, sem));
}



advTHANKSance,
*swfc
--
-------------------------------------------------------------------------------
Shu-Wie F Chen	             Columbia University Department of Computer Science
swfc@cs.columbia.edu	     500 W120th Street, New York, NY 10027