From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: X-Archive-Original-Message-ID: Date: Fri, 2 Feb 1996 07:27:36 -0500 (EST) From: Curt Smith Subject: AXP mutex lock code? 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--)) { 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