Implement soon-to-be-used rw_unlock() macro.

This commit is contained in:
Pawel Jakub Dawidek 2008-03-16 17:10:52 +00:00
parent 39887c5c2e
commit b12455f34e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177260
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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))