diff options
Diffstat (limited to 'include/litmus/wait.h')
-rw-r--r-- | include/litmus/wait.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/litmus/wait.h b/include/litmus/wait.h new file mode 100644 index 00000000000..7e20c0a4a1f --- /dev/null +++ b/include/litmus/wait.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef _LITMUS_WAIT_H_ | ||
2 | #define _LITMUS_WAIT_H_ | ||
3 | |||
4 | struct task_struct* __waitqueue_remove_first(wait_queue_head_t *wq); | ||
5 | struct task_struct* __waitqueue_peek_first(wait_queue_head_t *wq); | ||
6 | |||
7 | /* wrap regular wait_queue_t head */ | ||
8 | struct __prio_wait_queue { | ||
9 | wait_queue_t wq; | ||
10 | |||
11 | /* some priority point */ | ||
12 | lt_t priority; | ||
13 | /* break ties in priority by lower tie_breaker */ | ||
14 | unsigned int tie_breaker; | ||
15 | }; | ||
16 | |||
17 | typedef struct __prio_wait_queue prio_wait_queue_t; | ||
18 | |||
19 | static inline void init_prio_waitqueue_entry(prio_wait_queue_t *pwq, | ||
20 | struct task_struct* t, | ||
21 | lt_t priority) | ||
22 | { | ||
23 | init_waitqueue_entry(&pwq->wq, t); | ||
24 | pwq->priority = priority; | ||
25 | pwq->tie_breaker = 0; | ||
26 | } | ||
27 | |||
28 | static inline void init_prio_waitqueue_entry_tie(prio_wait_queue_t *pwq, | ||
29 | struct task_struct* t, | ||
30 | lt_t priority, | ||
31 | unsigned int tie_breaker) | ||
32 | { | ||
33 | init_waitqueue_entry(&pwq->wq, t); | ||
34 | pwq->priority = priority; | ||
35 | pwq->tie_breaker = tie_breaker; | ||
36 | } | ||
37 | |||
38 | unsigned int __add_wait_queue_prio_exclusive( | ||
39 | wait_queue_head_t* head, | ||
40 | prio_wait_queue_t *new); | ||
41 | |||
42 | static inline unsigned int add_wait_queue_prio_exclusive( | ||
43 | wait_queue_head_t* head, | ||
44 | prio_wait_queue_t *new) | ||
45 | { | ||
46 | unsigned long flags; | ||
47 | unsigned int passed; | ||
48 | |||
49 | spin_lock_irqsave(&head->lock, flags); | ||
50 | passed = __add_wait_queue_prio_exclusive(head, new); | ||
51 | |||
52 | spin_unlock_irqrestore(&head->lock, flags); | ||
53 | |||
54 | return passed; | ||
55 | } | ||
56 | |||
57 | |||
58 | #endif | ||