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

Function ksem_alloc

freebsd/kern/uipc_sem.c:302–329  ·  view source on GitHub ↗

* ksem object management including creation and reference counting * routines. */

Source from the content-addressed store, hash-verified

300 * routines.
301 */
302static struct ksem *
303ksem_alloc(struct ucred *ucred, mode_t mode, unsigned int value)
304{
305 struct ksem *ks;
306
307 mtx_lock(&ksem_count_lock);
308 if (nsems == p31b_getcfg(CTL_P1003_1B_SEM_NSEMS_MAX) || ksem_dead) {
309 mtx_unlock(&ksem_count_lock);
310 return (NULL);
311 }
312 nsems++;
313 mtx_unlock(&ksem_count_lock);
314 ks = malloc(sizeof(*ks), M_KSEM, M_WAITOK | M_ZERO);
315 ks->ks_uid = ucred->cr_uid;
316 ks->ks_gid = ucred->cr_gid;
317 ks->ks_mode = mode;
318 ks->ks_value = value;
319 cv_init(&ks->ks_cv, "ksem");
320 vfs_timestamp(&ks->ks_birthtime);
321 ks->ks_atime = ks->ks_mtime = ks->ks_ctime = ks->ks_birthtime;
322 refcount_init(&ks->ks_ref, 1);
323#ifdef MAC
324 mac_posixsem_init(ks);
325 mac_posixsem_create(ucred, ks);
326#endif
327
328 return (ks);
329}
330
331static struct ksem *
332ksem_hold(struct ksem *ks)

Callers 1

ksem_createFunction · 0.85

Calls 9

p31b_getcfgFunction · 0.85
mallocFunction · 0.85
vfs_timestampFunction · 0.85
refcount_initFunction · 0.85
mac_posixsem_initFunction · 0.85
mac_posixsem_createFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
cv_initFunction · 0.70

Tested by

no test coverage detected