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: Monty Brandenberg Subject: Re: mutex between processes? Date: 1998/08/07 Message-ID: <35CBBDEE.17958205@ne.mediaone.net>#1/1 X-Deja-AN: 379042228 Content-Transfer-Encoding: 7bit References: <35C85511.E31EBB9E@brighttiger.com> <35CAC907.497400F4@orga.com> <35CB2911.61856927@brighttiger.com> To: Aurel Balmosan Content-Type: text/plain; charset=us-ascii Organization: MCB, Inc. Mime-Version: 1.0 Reply-To: mcbinc@ne.mediaone.net.MAPS.SPAM Newsgroups: comp.unix.osf.osf1 Aurel Balmosan wrote: > > > The __MB() (memory barrier) is *absolutely* necessary for the spinlock to work > > Does it flush the second and third level cache of a processor to the main memory? > I saw also the WMB() command which I see as withdraw memory barrier. Shouldn't > a combination of MB and WMB be used? No, cache is coherent in all Alpha systems. MB (memory barrier) and WMB (write memory barrier) operate on small, cache-like structures called write buffers. These are misnamed as they are also involved with reading. Also note that using MB (or WMB) alone does *not* guarantee visibility by another processor or other system device. This requires slightly more sophisticated algorithms or the use of interlocked instructions. See section 5.6 of the Alpha SRM for a very important discussion of this. Much of what is in here applies on other systems as well and is understood by few programmers. For mutex and semaphore algorithms that avoid expensive interlocked operations, see papers by Leslie Lamport (of Dec SRC {or WRL?}). For seminal work, there's C.A.R. Hoare. Problems due to incorrect SMP algorithms are very difficult to debug. It is much easier to do the research and get it right the first time.... m -- Monty Brandenberg, Software Consultant MCB, Inc. mcbinc@ne.mediaone.net.MAPS.SPAM P.O. Box 426188 mcbinc@world.std.com.MAPS.SPAM Cambridge, MA 02142 617.864.6907