This commit is contained in:
Cloud Wu
2022-03-19 07:10:52 +08:00
parent eaba8f969c
commit d1ce950dc1
6 changed files with 37 additions and 21 deletions

View File

@@ -31,8 +31,7 @@ rwlock_rlock(struct rwlock *lock) {
static inline void
rwlock_wlock(struct rwlock *lock) {
int clear = 0;
while (!ATOM_CAS(&lock->write,clear,1)) {}
while (!ATOM_CAS(&lock->write,0,1)) {}
while(ATOM_LOAD(&lock->read)) {}
}