Subj : Re: Best locking methods To : comp.programming.threads From : Joe Seigh Date : Thu Apr 07 2005 08:54 am On Thu, 7 Apr 2005 04:56:26 +0200, Uenal Mutlu <520001085531-0001@t-online.de> wrote: > > Say, it is a sorted vector of structures. The vector has to grow > when new items need to be inserted. (...) > > Each item is a fixlen structure consisting of a unique key, plus its data. > Obviosly the writer threads are those who update the list. > The readers are free how they access the list; besides using a Find(key) > function they can also walk sequentially in the list, ie. in a for loop. > Access to an item is done via baseptr + the physical element number ("record > number"). > > This works fine using Critical Section's, but since there seem to be many > methods available I wondered whether there's maybe a significantly faster > method. What would others use for such a task? > > As to whether there's a faster method for mutual exclusion than Critical Section, don't you think they would be using it instead if it existed? Also, you've picked a data structure, vector, that's rather expensive to modify. A binary tree with PCOW (Partial Copy On Write) would work better but it's a rather advanced project. I don't think anyone has done one yet and it will probably be patented so you won't be able to use it for free and it will be too late to do a free implementation then. -- Joe Seigh .