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

Function mqueue_alloc

freebsd/kern/uipc_mqueue.c:1596–1617  ·  view source on GitHub ↗

* Allocate a message queue */

Source from the content-addressed store, hash-verified

1594 * Allocate a message queue
1595 */
1596static struct mqueue *
1597mqueue_alloc(const struct mq_attr *attr)
1598{
1599 struct mqueue *mq;
1600
1601 if (curmq >= maxmq)
1602 return (NULL);
1603 mq = uma_zalloc(mqueue_zone, M_WAITOK | M_ZERO);
1604 TAILQ_INIT(&mq->mq_msgq);
1605 if (attr != NULL) {
1606 mq->mq_maxmsg = attr->mq_maxmsg;
1607 mq->mq_msgsize = attr->mq_msgsize;
1608 } else {
1609 mq->mq_maxmsg = default_maxmsg;
1610 mq->mq_msgsize = default_msgsize;
1611 }
1612 mtx_init(&mq->mq_mutex, "mqueue lock", NULL, MTX_DEF);
1613 knlist_init_mtx(&mq->mq_rsel.si_note, &mq->mq_mutex);
1614 knlist_init_mtx(&mq->mq_wsel.si_note, &mq->mq_mutex);
1615 atomic_add_int(&curmq, 1);
1616 return (mq);
1617}
1618
1619/*
1620 * Destroy a message queue

Callers 2

mqfs_createFunction · 0.85
kern_kmq_openFunction · 0.85

Calls 3

mtx_initFunction · 0.85
knlist_init_mtxFunction · 0.85
uma_zallocFunction · 0.50

Tested by

no test coverage detected