Subject: Re: bug#7073: no pthread_spinlock_t on Mac OS 10.6.4

From: Paul Eggert <[email-masked]>
Date: Mon, 20 Sep 2010 16:38:07 -0700

On 09/20/10 14:38, Chen Guo wrote:

> How difficult would it be to implement a basic spinlock in gnulib, though?

Portably?  I'd think it'd be quite a pain, as it would require
figuring out this platform's atomic instructions, dealing with memory
barriers, and the like.

> I suppose a performance hit with mutexes beats no performance at all
> with missing spinlocks.

Yes.

> And regarding "take more work," I believe spinlocks and mutexes were
> basically interchangeable in terms of functionality in our sort
> algorithm; the work probably will be little more than a few #ifdefs
> and a s/pthread_mutex_t/pthread_spinlock_t/

Is that a reasonably-valid replacement in general, for code that uses
spin locks?  If so, we should implement this inside gnulib's pthread
module.  If not, it needs to be done inside coreutils, or perhaps
as a separate gnulib module.