From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,96676b7d032e1fb2,start X-Google-Attributes: gidfee84,public From: aoki@faerie.CS.Berkeley.EDU (Paul M. Aoki) Subject: Re: TEST and SET/Spin lock for Alpha/Unix? Date: 1995/11/18 Message-ID: <48jpti$pkl@agate.berkeley.edu>#1/1 X-Deja-AN: 119660310 references: <48imk7$j65@nntp.atlanta.com> organization: University of California at Berkeley reply-to: aoki@CS.Berkeley.EDU (Paul M. Aoki) newsgroups: comp.unix.osf.osf1 curts@compgen.com (Curt Smith) writes: | Anybody have the small bit of assembly it takes for a test and | set / spin lock in user space?? you might try using msem_lock(3). it tries to use the LDL_L/STL_C load-linked/store-conditional instructions to obtain a semaphore from user mode before calling __msleep to sleep on the semaphore. (if you use the MSEM_IF_NOWAIT flag, it returns immediately with an error instead of sleeping.) furthermore, it gets the multiprocessor memory consistency protocol (i.e., use of the MB memory barrier instruction -- see the alpha architecture manual) right. caveat 1: i have no idea how clustering affects all of this. i've only ever used standalone DS3000s and Sables. caveat 2: before osf/1 3.0 (the first multiprocessor version), the msem_* routines *didn't* use the MB instruction. hence, statically linking against pre-3.0 libraries is iffy if you are going to run the binaries on a multiprocessor. however, things are fine >= 3.0. -- Paul M. Aoki | University of California at Berkeley aoki@CS.Berkeley.EDU | Dept. of EECS, Computer Science Division (#1776) | Berkeley, CA 94720-1776