Lines Matching defs:q
43 msg_queue_t *q;
45 q = (msg_queue_t *)calloc(1, sizeof (msg_queue_t));
47 if (q) {
48 if (sema_init(&q->q_sema, 0, USYNC_THREAD, NULL) ||
49 pthread_mutex_init(&q->q_mutex, NULL)) {
50 free(q);
51 q = NULL;
55 return (q);
60 msg_queue_t *q,
76 (void) pthread_mutex_lock(&q->q_mutex);
78 if (q->q_head == NULL) {
79 ASSERT(!q->q_tail);
80 q->q_head = msg;
81 q->q_tail = msg;
83 ASSERT(q->q_tail);
84 q->q_tail->next = msg;
85 msg->prev = q->q_tail;
86 q->q_tail = msg;
89 (void) pthread_mutex_unlock(&q->q_mutex);
91 (void) sema_post(&q->q_sema);
98 msg_queue_t *q
103 while (sema_wait(&q->q_sema)) {
107 (void) pthread_mutex_lock(&q->q_mutex);
109 msg = q->q_head;
111 q->q_head = msg->next;
112 if (q->q_head == NULL) {
113 q->q_tail = NULL;
116 (void) pthread_mutex_unlock(&q->q_mutex);