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

Function lockmgr_slock_try

freebsd/kern/kern_lock.c:512–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510}
511
512static bool __always_inline
513lockmgr_slock_try(struct lock *lk, uintptr_t *xp, int flags, bool fp)
514{
515
516 /*
517 * If no other thread has an exclusive lock, or
518 * no exclusive waiter is present, bump the count of
519 * sharers. Since we have to preserve the state of
520 * waiters, if we fail to acquire the shared lock
521 * loop back and retry.
522 */
523 while (LK_CAN_SHARE(*xp, flags, fp)) {
524 if (atomic_fcmpset_acq_ptr(&lk->lk_lock, xp,
525 *xp + LK_ONE_SHARER)) {
526 return (true);
527 }
528 }
529 return (false);
530}
531
532static bool __always_inline
533lockmgr_sunlock_try(struct lock *lk, uintptr_t *xp)

Callers 3

lockmgr_slock_hardFunction · 0.85
lockmgr_lock_flagsFunction · 0.85
lockmgr_slockFunction · 0.85

Calls 1

LK_CAN_SHAREFunction · 0.85

Tested by

no test coverage detected