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: Aurel Balmosan Subject: Re: mutex between processes? Date: 1998/08/07 Message-ID: #1/1 X-Deja-AN: 378997497 X-Nntp-Posting-Host: 194.122.136.143 Sender: news@orga.com (News Administrator) References: <35C85511.E31EBB9E@brighttiger.com> <35CAC907.497400F4@orga.com> <35CB2911.61856927@brighttiger.com> Organization: ORGA Kartensysteme GmbH Newsgroups: comp.unix.osf.osf1 Jeff Denham wrote: > Whether a spinlock is appropriate for your app depends on > the size/duration of your critical sections. If you'll have > lots of contention of the lock or the lock is held for > "long" periods, then the system call is a win. There's > a crossover point where spinning no longer pays > off. Actually I want to use not a spinlock but a 4 byte integer (unsigned int) to hold an index (actually about 40 million). It only must be guaranteed that the write can write a value without a reader getting only a part of the written index. It does not matter if the reader get the old value. The writers could be managed via a spinlock or a semaphore that does not really matter. But the readers must never be blocked. > 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? Such as: MB(); ATOMIC....(); WMB(); -- Aurel Balmosan | Department SE-SW ORGA Kartensysteme GmbH | phone: +49 5254 991 824 An der Kapelle 2 | fax : +49 5254 991 749 33104 Paderborn, Germany | mailto:ab@orga.com