Subj : Re: experimental smr-based 100% lock-free eventcount schema for windows... To : comp.programming.threads From : SenderX Date : Tue Feb 01 2005 06:19 pm 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: DWORD ac_event_count_wait ( ac_event_count_t *_this, DWORD ec_cmp, DWORD timeout ) { register ac_event_count_t cmp, xchg; regitser ac_waitset_t *local_waitset = 0; void **hazard = ac_lfgc_get_hazard( 1 ); cmp.ec = _this->ec; cmp.active_waitset = _this->active_waitset; do { xchg.cmp = cmp.ec; if ( cmp.ec == ec_cmp ) { if ( ! cmp.active_waitset ) { if ( ! local_waitset ) { local_waitset = ac_waitset_cache_pop( &global_cache ); } xchg.active_waitset = local_waitset; } else { xchg.active_waitset = cmp.active_waitset; } } else { xchg.active_waitset = cmp.active_waitset; } *hazard = xchg.active_waitset; } while ( ! np_ac_atomic_dwcas_acq_dep ( _this, &cmp, &xchg ) ); [ ... ] } More to come a bit later... .