MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lockmgr_slock

Function lockmgr_slock

freebsd/kern/kern_lock.c:1223–1242  ·  view source on GitHub ↗

* Lightweight entry points for common operations. * * Functionality is similar to sx locks, in that none of the additional lockmgr * features are supported. To be clear, these are NOT supported: * 1. shared locking disablement * 2. returning with an error after sleep * 3. unlocking the interlock * * If in doubt, use lockmgr_lock_flags. */

Source from the content-addressed store, hash-verified

1221 * If in doubt, use lockmgr_lock_flags.
1222 */
1223int
1224lockmgr_slock(struct lock *lk, u_int flags, const char *file, int line)
1225{
1226 uintptr_t x;
1227
1228 MPASS((flags & LK_TYPE_MASK) == LK_SHARED);
1229 MPASS((flags & LK_INTERLOCK) == 0);
1230 MPASS((lk->lock_object.lo_flags & LK_NOSHARE) == 0);
1231
1232 if (LK_CAN_WITNESS(flags))
1233 WITNESS_CHECKORDER(&lk->lock_object, LOP_NEWORDER,
1234 file, line, NULL);
1235 x = lockmgr_read_value(lk);
1236 if (__predict_true(lockmgr_slock_try(lk, &x, flags, true))) {
1237 lockmgr_note_shared_acquire(lk, 0, 0, file, line, flags);
1238 return (0);
1239 }
1240
1241 return (lockmgr_slock_hard(lk, flags | LK_ADAPTIVE, NULL, file, line, NULL));
1242}
1243
1244int
1245lockmgr_xlock(struct lock *lk, u_int flags, const char *file, int line)

Callers 1

vop_lockFunction · 0.85

Calls 3

lockmgr_slock_tryFunction · 0.85
lockmgr_slock_hardFunction · 0.85

Tested by

no test coverage detected