Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Curt Smith <curts@compgen.com>
Subject: AXP mutex lock code?
Date: Fri, 2 Feb 1996 07:27:36 -0500 (EST)	[thread overview]
Message-ID: <ae2d5b4f4a8049174a6b01a7347d8517.axp-list@archive.invalid> (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

                 reply	other threads:[~1996-02-02 12:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

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