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

Function _thread_lock

freebsd/kern/kern_mutex.c:825–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823_thread_lock(struct thread *td, int opts, const char *file, int line)
824#else
825void
826_thread_lock(struct thread *td)
827#endif
828{
829 struct mtx *m;
830 uintptr_t tid;
831
832 tid = (uintptr_t)curthread;
833
834 if (__predict_false(LOCKSTAT_PROFILE_ENABLED(spin__acquire)))
835 goto slowpath_noirq;
836 spinlock_enter();
837 m = td->td_lock;
838 thread_lock_validate(m, 0, file, line);
839 if (__predict_false(m == &blocked_lock))
840 goto slowpath_unlocked;
841 if (__predict_false(!_mtx_obtain_lock(m, tid)))
842 goto slowpath_unlocked;
843 if (__predict_true(m == td->td_lock)) {
844 WITNESS_LOCK(&m->lock_object, LOP_EXCLUSIVE, file, line);
845 return;
846 }
847 _mtx_release_lock_quick(m);
848slowpath_unlocked:
849 spinlock_exit();
850slowpath_noirq:
851#if LOCK_DEBUG > 0
852 thread_lock_flags_(td, opts, file, line);
853#else
854 thread_lock_flags_(td, 0, 0, 0);
855#endif
856}
857#endif
858
859void

Callers

nothing calls this directly

Calls 4

thread_lock_validateFunction · 0.85
thread_lock_flags_Function · 0.85
spinlock_enterFunction · 0.50
spinlock_exitFunction · 0.50

Tested by

no test coverage detected