Subj : Re: Best locking methods To : comp.programming.threads From : Uenal Mutlu Date : Thu Apr 07 2005 04:35 am "Joe Seigh" wrote > On Wed, 6 Apr 2005 18:29:17 +0200, Uenal Mutlu wrote: > > > What is the best (fastest) method to synchronize access > > to a memory block which is shared by say 5 reader threads > > and 5 writer threads? The memblock can be realloced by > > the writers and hence the pointer can change. > > Platform is x86 Linux and Windows. > > > If contention is fairly low, then a simple pthread mutex or > windows critical section will do. > > For high contention, a reader writer solution, lock-free > COW (Copy On Write), is better. You can use RCU, SMR, > or atomic_ptr. Don't bother with rwlocks which don't perform > any better than mutexes. IMHO COW and RCU would be slow with this data structure since they seem to use a temporary copy, and I think the overhead would be too costly. Mutex is too slow; would need something faster than Critical Section. I've yet to study how SMR and atomic_ptr do work. .