diff --git a/share/man/man9/rwlock.9 b/share/man/man9/rwlock.9 index 94e53a154883..4bc831239422 100644 --- a/share/man/man9/rwlock.9 +++ b/share/man/man9/rwlock.9 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 25, 2007 +.Dd March 16, 2008 .Dt RWLOCK 9 .Os .Sh NAME @@ -36,6 +36,7 @@ .Nm rw_wlock , .Nm rw_runlock , .Nm rw_wunlock , +.Nm rw_unlock , .Nm rw_try_upgrade , .Nm rw_downgrade , .Nm rw_sleep , @@ -62,6 +63,8 @@ .Fn rw_runlock "struct rwlock *rw" .Ft void .Fn rw_wunlock "struct rwlock *rw" +.Ft void +.Fn rw_unlock "struct rwlock *rw" .Ft int .Fn rw_try_upgrade "struct rwlock *rw" .Ft void @@ -179,6 +182,11 @@ This function releases a shared lock previously acquired by .It Fn rw_wunlock "struct rwlock *rw" This function releases an exclusive lock previously acquired by .Fn rw_wlock . +.It Fn rw_unlock "struct rwlock *rw" +This function releases a shared lock previously acquired by +.Fn rw_rlock +or an exclusive lock previously acquired by +.Fn rw_wlock . .It Fn rw_try_upgrade "struct rwlock *rw" Attempt to upgrade a single shared lock to an exclusive lock. The current thread must hold a shared lock of diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h index fe7127b7354a..d793e341a207 100644 --- a/sys/sys/rwlock.h +++ b/sys/sys/rwlock.h @@ -167,6 +167,12 @@ void _rw_assert(struct rwlock *rw, int what, const char *file, int line); #define rw_runlock(rw) _rw_runlock((rw), LOCK_FILE, LOCK_LINE) #define rw_try_upgrade(rw) _rw_try_upgrade((rw), LOCK_FILE, LOCK_LINE) #define rw_downgrade(rw) _rw_downgrade((rw), LOCK_FILE, LOCK_LINE) +#define rw_unlock(rw) do { \ + if (rw_wowned(rw)) \ + rw_wunlock(rw); \ + else \ + rw_runlock(rw); \ +} while (0) #define rw_sleep(chan, rw, pri, wmesg, timo) \ _sleep((chan), &(rw)->lock_object, (pri), (wmesg), (timo))