Subj : Re: Best locking methods To : comp.programming.threads From : Joe Seigh Date : Wed Apr 06 2005 02:09 pm On Wed, 6 Apr 2005 18:29:17 +0200, Uenal Mutlu <520001085531-0001@t-online.de> 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. -- Joe Seigh .