@ -392,10 +392,9 @@ ck_epoch_synchronize(struct ck_epoch_record *record)
bool active ;
bool active ;
/*
/*
* Technically , we are vulnerable to an overflow in presence of
* If UINT_MAX concurrent mutations were to occur then
* multiple writers . Realistically , this will require UINT_MAX scans .
* it is possible to encounter an ABA - issue . If this is a concern ,
* You can use epoch - protected sections on the writer - side if this is a
* consider tuning write - side concurrency .
* concern .
*/
*/
delta = epoch = ck_pr_load_uint ( & global - > epoch ) ;
delta = epoch = ck_pr_load_uint ( & global - > epoch ) ;
goal = epoch + CK_EPOCH_GRACE ;
goal = epoch + CK_EPOCH_GRACE ;
@ -408,9 +407,11 @@ ck_epoch_synchronize(struct ck_epoch_record *record)
ck_pr_fence_memory ( ) ;
ck_pr_fence_memory ( ) ;
for ( i = 0 , cr = NULL ; i < CK_EPOCH_GRACE - 1 ; cr = NULL , i + + ) {
for ( i = 0 , cr = NULL ; i < CK_EPOCH_GRACE - 1 ; cr = NULL , i + + ) {
bool r ;
/*
/*
* Determine whether all threads have observed the current
* Determine whether all threads have observed the current
* epoch . We can get away without a fence here .
* epoch with respect to the updates on invocation .
*/
*/
while ( cr = ck_epoch_scan ( global , cr , delta , & active ) ,
while ( cr = ck_epoch_scan ( global , cr , delta , & active ) ,
cr ! = NULL ) {
cr ! = NULL ) {
@ -447,11 +448,18 @@ ck_epoch_synchronize(struct ck_epoch_record *record)
* it is possible to overflow the epoch value if we apply
* it is possible to overflow the epoch value if we apply
* modulo - 3 arithmetic .
* modulo - 3 arithmetic .
*/
*/
if ( ck_pr_cas_uint_value ( & global - > epoch , delta , delta + 1 ,
r = ck_pr_cas_uint_value ( & global - > epoch , delta , delta + 1 ,
& delta ) = = true ) {
& delta ) ;
delta = delta + 1 ;
/* Order subsequent thread active checks. */
ck_pr_fence_atomic_load ( ) ;
/*
* If CAS has succeeded , then set delta to latest snapshot .
* Otherwise , we have just acquired latest snapshot .
*/
delta = delta + r ;
continue ;
continue ;
}
reload :
reload :
if ( ( goal > epoch ) & ( delta > = goal ) ) {
if ( ( goal > epoch ) & ( delta > = goal ) ) {
@ -467,6 +475,7 @@ reload:
}
}
}
}
ck_pr_fence_release ( ) ;
record - > epoch = delta ;
record - > epoch = delta ;
return ;
return ;
}
}