20 #ifndef _XENO_NUCLEUS_SCHEDQUEUE_H
21 #define _XENO_NUCLEUS_SCHEDQUEUE_H
23 #include <nucleus/queue.h>
25 #ifdef CONFIG_XENO_OPT_SCALABLE_SCHED
32 #define XNSCHED_MLQ_LEVELS 264
34 #if BITS_PER_LONG * BITS_PER_LONG < XNSCHED_MLQ_LEVELS
35 #error "Internal bitmap cannot hold so many priority levels"
38 #define __MLQ_LONGS ((XNSCHED_MLQ_LEVELS+BITS_PER_LONG-1)/BITS_PER_LONG)
42 int loprio, hiprio, elems;
43 unsigned long himap, lomap[__MLQ_LONGS];
44 struct xnqueue queue[XNSCHED_MLQ_LEVELS];
50 void initmlq(
struct xnsched_mlq *q,
int loprio,
int hiprio);
52 void addmlq(
struct xnsched_mlq *q,
53 struct xnpholder *holder,
int idx,
int lifo);
55 void removemlq(
struct xnsched_mlq *q,
struct xnpholder *holder);
57 struct xnpholder *findmlqh(
struct xnsched_mlq *q,
int prio);
59 struct xnpholder *getheadmlq(
struct xnsched_mlq *q);
61 struct xnpholder *getmlq(
struct xnsched_mlq *q);
63 struct xnpholder *nextmlq(
struct xnsched_mlq *q,
66 static inline int countmlq(
struct xnsched_mlq *q)
71 static inline int emptymlq_p(
struct xnsched_mlq *q)
76 static inline int indexmlq(
struct xnsched_mlq *q,
int prio)
79 prio >= q->loprio && prio <= q->hiprio,
80 xnpod_fatal(
"priority level %d is out of range ", prio));
89 return q->hiprio - prio;
92 static inline int ffsmlq(
struct xnsched_mlq *q)
94 int hi = ffnz(q->himap);
95 int lo = ffnz(q->lomap[hi]);
96 return hi * BITS_PER_LONG + lo;
99 static inline void insertmlql(
struct xnsched_mlq *q,
100 struct xnpholder *holder,
int prio)
102 addmlq(q, holder, indexmlq(q, prio), 1);
105 static inline void insertmlqf(
struct xnsched_mlq *q,
106 struct xnpholder *holder,
int prio)
108 addmlq(q, holder, indexmlq(q, prio), 0);
111 static inline void appendmlq(
struct xnsched_mlq *q,
struct xnpholder *holder)
113 addmlq(q, holder, indexmlq(q, q->hiprio), 0);
116 static inline void prependmlq(
struct xnsched_mlq *q,
struct xnpholder *holder)
118 addmlq(q, holder, indexmlq(q, q->loprio), 1);
121 typedef struct xnsched_mlq xnsched_queue_t;
123 #define sched_initpq initmlq
124 #define sched_emptypq_p emptymlq_p
125 #define sched_insertpql insertmlql
126 #define sched_insertpqf insertmlqf
127 #define sched_appendpq appendmlq
128 #define sched_prependpq prependmlq
129 #define sched_removepq removemlq
130 #define sched_getheadpq getheadmlq
131 #define sched_nextpq nextmlq
132 #define sched_getpq getmlq
133 #define sched_findpqh findmlqh
137 typedef xnpqueue_t xnsched_queue_t;
139 #define sched_initpq(q, minp, maxp) initpq(q)
140 #define sched_emptypq_p emptypq_p
141 #define sched_insertpql insertpql
142 #define sched_insertpqf insertpqf
143 #define sched_appendpq appendpq
144 #define sched_prependpq prependpq
145 #define sched_removepq removepq
146 #define sched_getheadpq getheadpq
147 #define sched_nextpq nextpq
148 #define sched_getpq getpq
149 #define sched_findpqh findpqh