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: 379859876 References: <35C85511.E31EBB9E@brighttiger.com> <35CAC907.497400F4@orga.com> <35CB2911.61856927@brighttiger.com> <35CF6191.3BB020B5@ne.mediaone.net> Organization: University of Colorado Newsgroups: comp.unix.osf.osf1 Monty Brandenberg writes: > > 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 --- Look, if I'm just incrementing a variable (the problem being described by the person in question) there's no reason to even *hint* at the possibility of a context switch forced by the thread library during that incremenet. E.g., if I'm going pthread_mutex_lock(foo); counter++; pthread_mutex_unlock(foo); it will take more time to get into/out of the O/S than to simply way. Many performance oriented programmers would know this and exercise proper judgement about when to use a spinlock. However, without representative & provided "spinlock" code, even expert programmers will screw up the WB's, MB's and the like needed for correctness. We shouldn't assume all programmers don't know how to write concurrent code. -- Dirk Grunwald Assoc. Prof, Univ. of Colorado at Boulder