Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* AXP mutex lock code?
@ 1996-02-02 12:27 Curt Smith
  0 siblings, 0 replies; only message in thread
From: Curt Smith @ 1996-02-02 12:27 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-02-02 12:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-02-02 12:27 AXP mutex lock code? Curt Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox