1#ifndef _KERN_MPQUEUE_H
2#define _KERN_MPQUEUE_H
3#include <kern/locks.h>
4
5__BEGIN_DECLS
6
7#ifdef MACH_KERNEL_PRIVATE
8
9#include <kern/priority_queue.h>
10
11/*----------------------------------------------------------------*/
12/*
13 * Define macros for queues with locks.
14 */
15struct mpqueue_head {
16 struct queue_entry head; /* header for queue */
17 struct priority_queue_deadline_min mpq_pqhead;
18 uint64_t earliest_soft_deadline;
19 uint64_t count;
20 lck_ticket_t lock_data;
21};
22
23typedef struct mpqueue_head mpqueue_head_t;
24
25#define mpqueue_init(q, lck_grp, lck_attr) \
26MACRO_BEGIN \
27 queue_init(&(q)->head); \
28 lck_ticket_init(&(q)->lock_data, lck_grp); \
29 priority_queue_init(&(q)->mpq_pqhead); \
30MACRO_END
31
32#define mpenqueue_tail(q, elt) \
33MACRO_BEGIN \
34 lck_ticket_lock(&(q)->lock_data, LCK_GRP_NULL); \
35 enqueue_tail(&(q)->head, elt); \
36 lck_ticket_unlock(&(q)->lock_data); \
37MACRO_END
38
39#define mpdequeue_head(q, elt) \
40MACRO_BEGIN \
41 lck_ticket_lock(&(q)->lock_data, LCK_GRP_NULL); \
42 if (queue_empty(&(q)->head)) \
43 *(elt) = 0; \
44 else \
45 *(elt) = dequeue_head(&(q)->head); \
46 lck_ticket_unlock(&(q)->lock_data); \
47MACRO_END
48
49#endif /* MACH_KERNEL_PRIVATE */
50
51__END_DECLS
52
53
54#endif /* _KERN_QUEUE_H */
55