AXP mutex lock code?

Curt Smith (curts@compgen.com)
Fri, 2 Feb 1996 07:27:36 -0500 (EST)

Hi,

I'm writing a simple function set for DEC Unix on Alpha and wonder
if you have any better code for Mutex locks than what I've included here?

void
spin_lock(int *lock) {
int spins;

spins = spin_count;

while (_msem_tas(lock) !=0 ) {
if (!(spins--)) {
<block/yield>
spins = spin_count;
}
}
}

/*
* release the lock.
*/

void
spin_unlock(int *lock) {
mb(); /* order exit from critical section */
*lock = 0; /* release lock */
mb(); /* order release of lock */
}

FYI: I'm told that the DEC Unix libc.[so,a] function if _msem_tas() is
a wrapper to AXP test/set.

Any idea what mb() is needed for?

Any code that would be portable between BOTH DEC Unix and Linux on AXP?

Like an implimimentation of mutex_lock() { asm ("axp_assembly"); } ?

Thanks.

Curt Smith
curts@compgen.com



Feedback | Store | News | Support | Product Errata | About Us | Linux Info | Search | JumpWords
No Frames | Show Frames

Copyright © 1995-1997 Red Hat Software. Legal notices