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

Function lockmgr_slock_adaptive

freebsd/kern/kern_lock.c:548–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546}
547
548static bool
549lockmgr_slock_adaptive(struct lock_delay_arg *lda, struct lock *lk, uintptr_t *xp,
550 int flags)
551{
552 struct thread *owner;
553 uintptr_t x;
554
555 x = *xp;
556 MPASS(x != LK_UNLOCKED);
557 owner = (struct thread *)LK_HOLDER(x);
558 for (;;) {
559 MPASS(owner != curthread);
560 if (owner == (struct thread *)LK_KERNPROC)
561 return (false);
562 if ((x & LK_SHARE) && LK_SHARERS(x) > 0)
563 return (false);
564 if (owner == NULL)
565 return (false);
566 if (!TD_IS_RUNNING(owner))
567 return (false);
568 if ((x & LK_ALL_WAITERS) != 0)
569 return (false);
570 lock_delay(lda);
571 x = lockmgr_read_value(lk);
572 if (LK_CAN_SHARE(x, flags, false)) {
573 *xp = x;
574 return (true);
575 }
576 owner = (struct thread *)LK_HOLDER(x);
577 }
578}
579
580static __noinline int
581lockmgr_slock_hard(struct lock *lk, u_int flags, struct lock_object *ilk,

Callers 1

lockmgr_slock_hardFunction · 0.85

Calls 2

lock_delayFunction · 0.85
LK_CAN_SHAREFunction · 0.85

Tested by

no test coverage detected