Re: [PATCH v2] Make xmalloc and xrealloc thread-safe
On Wed, 7 Apr 2010, Shawn Pearce wrote:
Show 12 quoted lines
> On Wed, Apr 7, 2010 at 6:17 AM, Nicolas Pitre <nico@fluxnic.net> wrote:
> > Yet, the memset() issue comes up only because pthread_t is meant to be
> > an opaque type. The only information we would need here is the actual
> > thread ID as returned by gettid() on Linux or GetCurrentThreadId() on
> > Windows, and then the read_mutex_owner could be a simple atomically
> > modifiable integer. But what about other pthread-capable non Linux
> > systems?
>
> Indeed. If Windows threads are atomic words, then actually you don't
> need that double mutex in the emulation layer, and can instead use the
> atomic word to determine ownership. Which makes this entire debate
> somewhat moot, doesn't it?