From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,a3ae14aeae49226 X-Google-Attributes: gidfee84,public From: Dirk Grunwald Subject: Re: mutex between processes? Date: 1998/08/10 Message-ID: #1/1 X-Deja-AN: 379814227 References: <35C85511.E31EBB9E@brighttiger.com> <35CAC907.497400F4@orga.com> <35CB2911.61856927@brighttiger.com> Organization: University of Colorado Newsgroups: comp.unix.osf.osf1 Jeff Denham writes: > The __MB() (memory barrier) is *absolutely* necessary for the > spinlock to work on an MP system. In Dirk's example, though, I'm > pretty sure that the __MB() in the release() routine is in the wrong > place -- it should be before the clearing of the lock, not > after. This guarantees that the updates to the object being locked > are seen by other processors before they see that the lock is clear, > grab it, and see stale state in the object. -- Yeah, actually the "may not be needed" comment is more because I'm not certain about the semantics of the builtin locking routines. If they already do WMB/MB, then it's not needed. You'd really need to take a look at the assembly code produced in a little more detail. This, frankly, is why Digital should have provided & established spinlocks, rather than insisting everyone use pthread mutex locks, which have a lot of extra overhead. Sometimes portability is much less important than performance. -- Dirk Grunwald Assoc. Prof, Univ. of Colorado at Boulder