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

Function _mtx_init

freebsd/kern/kern_mutex.c:1126–1165  ·  view source on GitHub ↗

* Mutex initialization routine; initialize lock `m' of type contained in * `opts' with options contained in `opts' and name `name.' The optional * lock type `type' is used as a general lock category name for use with * witness. */

Source from the content-addressed store, hash-verified

1124 * witness.
1125 */
1126void
1127_mtx_init(volatile uintptr_t *c, const char *name, const char *type, int opts)
1128{
1129 struct mtx *m;
1130 struct lock_class *class;
1131 int flags;
1132
1133 m = mtxlock2mtx(c);
1134
1135 MPASS((opts & ~(MTX_SPIN | MTX_QUIET | MTX_RECURSE |
1136 MTX_NOWITNESS | MTX_DUPOK | MTX_NOPROFILE | MTX_NEW)) == 0);
1137 ASSERT_ATOMIC_LOAD_PTR(m->mtx_lock,
1138 ("%s: mtx_lock not aligned for %s: %p", __func__, name,
1139 &m->mtx_lock));
1140
1141 /* Determine lock class and lock flags. */
1142 if (opts & MTX_SPIN)
1143 class = &lock_class_mtx_spin;
1144 else
1145 class = &lock_class_mtx_sleep;
1146 flags = 0;
1147 if (opts & MTX_QUIET)
1148 flags |= LO_QUIET;
1149 if (opts & MTX_RECURSE)
1150 flags |= LO_RECURSABLE;
1151 if ((opts & MTX_NOWITNESS) == 0)
1152 flags |= LO_WITNESS;
1153 if (opts & MTX_DUPOK)
1154 flags |= LO_DUPOK;
1155 if (opts & MTX_NOPROFILE)
1156 flags |= LO_NOPROFILE;
1157 if (opts & MTX_NEW)
1158 flags |= LO_NEW;
1159
1160 /* Initialize mutex. */
1161 lock_init(&m->lock_object, class, name, type, flags);
1162
1163 m->mtx_lock = MTX_UNOWNED;
1164 m->mtx_recurse = 0;
1165}
1166
1167/*
1168 * Remove lock `m' from all_mtx queue. We don't allow MTX_QUIET to be

Callers

nothing calls this directly

Calls 1

lock_initFunction · 0.85

Tested by

no test coverage detected