1 #ifndef _KERN_MPQUEUE_H
2 #define _KERN_MPQUEUE_H
3 #include <kern/locks.h>
7 #ifdef MACH_KERNEL_PRIVATE
9 #include <kern/priority_queue.h>
11 /*----------------------------------------------------------------*/
13 * Define macros for queues with locks.
16 struct queue_entry head
; /* header for queue */
17 struct priority_queue_deadline_min mpq_pqhead
;
18 uint64_t earliest_soft_deadline
;
21 #if defined(__i386__) || defined(__x86_64__)
22 lck_mtx_ext_t lock_data_ext
;
26 typedef struct mpqueue_head mpqueue_head_t
;
28 #if defined(__i386__) || defined(__x86_64__)
30 #define mpqueue_init(q, lck_grp, lck_attr) \
32 queue_init(&(q)->head); \
33 lck_mtx_init_ext(&(q)->lock_data, \
34 &(q)->lock_data_ext, \
37 (q)->earliest_soft_deadline = UINT64_MAX; \
39 priority_queue_init(&(q)->mpq_pqhead); \
44 #define mpqueue_init(q, lck_grp, lck_attr) \
46 queue_init(&(q)->head); \
47 lck_mtx_init(&(q)->lock_data, \
50 priority_queue_init(&(q)->mpq_pqhead); \
55 #define mpenqueue_tail(q, elt) \
57 lck_mtx_lock_spin_always(&(q)->lock_data); \
58 enqueue_tail(&(q)->head, elt); \
59 lck_mtx_unlock_always(&(q)->lock_data); \
62 #define mpdequeue_head(q, elt) \
64 lck_mtx_lock_spin_always(&(q)->lock_data); \
65 if (queue_empty(&(q)->head)) \
68 *(elt) = dequeue_head(&(q)->head); \
69 lck_mtx_unlock_always(&(q)->lock_data); \
72 #endif /* MACH_KERNEL_PRIVATE */
77 #endif /* _KERN_QUEUE_H */