static inline voidrwlock_rlock(struct rwlock *lock) { for (;;) { while(lock->write) { __sync_synchronize(); } __sync_add_and_fetch(&lock->read,1); if (lock->write) { __sync_sub_and_fetch(&lock->read,1); } else { break; } }}
中while(lock->write) { __sync_synchronize(); }这段应该可以不要把
__sync_add_and_fetch(&lock->read,1); 已经有acquire语义了, 云风大哥能解释下吗
云风大哥 能解释下吗 我还是不能理解感觉while(lock->write) { __sync_synchronize(); }有点多余 - 回复 | (2586) | ctx | 2012-09-08 12:46:18