On Sun, Sep 29, 2013 at 11:09 PM, Hooman Fazaeli <hoomanfaza...@gmail.com>wrote:
> Hi, > > For rwlock(9), there is no rwlock_upgrade function. > Is it safe to use rw_wlock() for that purpose? In other words, Does calling > rw_wlock() upgradeanalready r-locked lock? No, calling rw_wlock when you hold the lock in read mode will deadlock. lockmgr(9) supports LK_UPGRADE, but note (see the recent commit for LK_TRYUPGRADE) that LK_UPGRADE, if it cannot do the upgrade immediately, e.g. due to multiple shared lockers, will unlock and wait to finish the upgrade. In general, the idea is that upgrade is not a good operation, since there's no way to know ahead of time if it can be done without a lock release. So code is better off explicitly unlocking the shared/read-mode lock and explicitly blocking for an exclusive/write lock. Thanks, matthew _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"