X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=urcu.h;h=79d9464b0be63142fb51cb2f00d11edb5996441d;hb=b0b31506add8085c1f8839915f8e322d05d4fa4b;hp=1b663c7ff1492e3beeab7832a592e6c2b7d90925;hpb=ae878d0dcc291dba7c5722eed13294195a64409e;p=urcu.git diff --git a/urcu.h b/urcu.h index 1b663c7..79d9464 100644 --- a/urcu.h +++ b/urcu.h @@ -130,6 +130,13 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, #define SIGURCU SIGUSR1 +/* + * If a reader is really non-cooperative and refuses to commit its + * urcu_active_readers count to memory (there is no barrier in the reader + * per-se), kick it after a few loops waiting for it. + */ +#define KICK_READER_LOOPS 10000 + #ifdef DEBUG_YIELD #include #include @@ -234,8 +241,10 @@ static inline void rcu_read_lock(void) tmp = urcu_active_readers; /* urcu_gp_ctr = RCU_GP_COUNT | (~RCU_GP_CTR_BIT or RCU_GP_CTR_BIT) */ + /* The data dependency "read urcu_gp_ctr, write urcu_active_readers", + * serializes those two memory operations. */ if (likely(!(tmp & RCU_GP_CTR_NEST_MASK))) - urcu_active_readers = urcu_gp_ctr; + urcu_active_readers = ACCESS_ONCE(urcu_gp_ctr); else urcu_active_readers = tmp + RCU_GP_COUNT; /*