blob: 62884f5eb9c8f6db1cd20ee8fe1a23fe7831134e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef _LITMUS_WAIT_H_
#define _LITMUS_WAIT_H_
struct task_struct* __waitqueue_remove_first(wait_queue_head_t *wq);
/* wrap regular wait_queue_t head */
struct __prio_wait_queue {
wait_queue_t wq;
/* some priority point */
lt_t priority;
};
typedef struct __prio_wait_queue prio_wait_queue_t;
static inline void init_prio_waitqueue_entry(prio_wait_queue_t *pwq,
struct task_struct* t,
lt_t priority)
{
init_waitqueue_entry(&pwq->wq, t);
pwq->priority = priority;
}
static inline unsigned int __add_wait_queue_prio_exclusive(
wait_queue_head_t* head,
prio_wait_queue_t *new)
{
struct list_head *pos;
unsigned int passed = 0;
new->wq.flags |= WQ_FLAG_EXCLUSIVE;
/* find a spot where the new entry is less than the next */
list_for_each(pos, &head->task_list) {
prio_wait_queue_t* queued = list_entry(pos, prio_wait_queue_t,
wq.task_list);
if (unlikely(lt_before(new->priority, queued->priority))) {
/* pos is not less than new, thus insert here */
__list_add(&new->wq.task_list, pos->prev, pos);
goto out;
}
passed++;
}
/* if we get to this point either the list is empty or every entry
* queued element is less than new.
* Let's add new to the end. */
list_add_tail(&new->wq.task_list, &head->task_list);
out:
return passed;
}
#endif
|