Subj : Re: experimental smr-based 100% lock-free eventcount schema for windows... To : comp.programming.threads From : Joseph Seigh Date : Wed Feb 02 2005 07:52 am On Tue, 1 Feb 2005 18:19:40 -0800, SenderX wrote: > There a race-condition wrt incrementing the eventcount and signalling... > > >> typedef struct ac_event_count_ >> { >> volatile ac_waitset_t *active_waitset; >> DWORD ec; >> >> } ac_event_count_t; > > needs to be modified atomically using dwcas. Here is what I am getting at > for the waiting side: I don't think you have to atomically do both. For signaling you can 1) atomically increment the eventcount 2) atomically swap the current event object with a new unsignaled event object. 3) signal the swapped out (old) event object and drop the reference to it. Old event object will be GC'd when there are no waiters using it. and waiting is 1) get pointer to current event object. 2) atomically compare current eventcount with local copy to see if eventcount has changed 3) if eventcount unchanged, wait on event object. The pointers used for the event object are some form of smart pointer, e.g. atomic_ptr, rcu, smr, etc... -- Joe Seigh .