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/10 Message-ID: <35CF6191.3BB020B5@ne.mediaone.net>#1/1 X-Deja-AN: 379831334 Content-Transfer-Encoding: 7bit References: <35C85511.E31EBB9E@brighttiger.com> <35CAC907.497400F4@orga.com> <35CB2911.61856927@brighttiger.com> To: Dirk Grunwald 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 Dirk Grunwald wrote: > > 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. For user-mode code? I'll have to mildly-to-strongly disagree with that. Having one or more threads eating their entire scheduling quantum in a spin while starving the lock holder isn't generally a path to performance or responsiveness. One place where you can see this in action is on the BeOS and documented in the last two newsletters which should be available publicly. Here, the OS supplies an improved version of semaphores called benaphores which avoids syscalls in the absence of contention. The two recent newsletters document what happens with naive coding which results in high ping-pong rates between threads and the case of a third thread that can consume a scheduling quantum. The situation with a user-mode spinlock is actually worse. A correct-but- naive multithreaded application that used spinlocks would have higher latencies and lower throughput than a correct-but-naive version that used syscall-based mutex and semaphore services. One result would be a continuous stream of newsgroup threads claiming Digital Unix SMP sucks. I'll disagree with myself with some conditions: supplying spinlock code to usermode, with suitable warnings and tutorials, could provide a better path for some applications. It would also allow programmers to avoid having to invent this themselves should they insist on going down this route. This would encapsulate the platform requirements for correct SMP communication which most programmers aren't going to code correctly. Question to research: do the TIS services support user-mode spinlocks? 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