diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-21 14:37:36 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-21 14:37:36 -0400 |
commit | f5d05880c01fe2e25dbe06c69d55b5e3d4c1a82c (patch) | |
tree | f6efab5be26115b248ab0b360eeb73e9dd5586dc | |
parent | eab1497d8b46a2367a78d47a3bc35b9a1b68e2c2 (diff) |
Add priority-ordered wait_queue_t implementation
Will be used by MPCP implementation.
-rw-r--r-- | include/litmus/litmus.h | 2 | ||||
-rw-r--r-- | include/litmus/wait.h | 54 | ||||
-rw-r--r-- | litmus/sched_gsn_edf.c | 1 | ||||
-rw-r--r-- | litmus/sched_pfp.c | 1 | ||||
-rw-r--r-- | litmus/sched_psn_edf.c | 1 |
5 files changed, 57 insertions, 2 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index a2a694e20be8..b5d8abb4aea5 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h | |||
@@ -26,8 +26,6 @@ static inline int in_list(struct list_head* list) | |||
26 | ); | 26 | ); |
27 | } | 27 | } |
28 | 28 | ||
29 | struct task_struct* __waitqueue_remove_first(wait_queue_head_t *wq); | ||
30 | |||
31 | #define NO_CPU 0xffffffff | 29 | #define NO_CPU 0xffffffff |
32 | 30 | ||
33 | void litmus_fork(struct task_struct *tsk); | 31 | void litmus_fork(struct task_struct *tsk); |
diff --git a/include/litmus/wait.h b/include/litmus/wait.h new file mode 100644 index 000000000000..62884f5eb9c8 --- /dev/null +++ b/include/litmus/wait.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #ifndef _LITMUS_WAIT_H_ | ||
2 | #define _LITMUS_WAIT_H_ | ||
3 | |||
4 | struct task_struct* __waitqueue_remove_first(wait_queue_head_t *wq); | ||
5 | |||
6 | /* wrap regular wait_queue_t head */ | ||
7 | struct __prio_wait_queue { | ||
8 | wait_queue_t wq; | ||
9 | |||
10 | /* some priority point */ | ||
11 | lt_t priority; | ||
12 | }; | ||
13 | |||
14 | typedef struct __prio_wait_queue prio_wait_queue_t; | ||
15 | |||
16 | static inline void init_prio_waitqueue_entry(prio_wait_queue_t *pwq, | ||
17 | struct task_struct* t, | ||
18 | lt_t priority) | ||
19 | { | ||
20 | init_waitqueue_entry(&pwq->wq, t); | ||
21 | pwq->priority = priority; | ||
22 | } | ||
23 | |||
24 | static inline unsigned int __add_wait_queue_prio_exclusive( | ||
25 | wait_queue_head_t* head, | ||
26 | prio_wait_queue_t *new) | ||
27 | { | ||
28 | struct list_head *pos; | ||
29 | unsigned int passed = 0; | ||
30 | |||
31 | new->wq.flags |= WQ_FLAG_EXCLUSIVE; | ||
32 | |||
33 | /* find a spot where the new entry is less than the next */ | ||
34 | list_for_each(pos, &head->task_list) { | ||
35 | prio_wait_queue_t* queued = list_entry(pos, prio_wait_queue_t, | ||
36 | wq.task_list); | ||
37 | |||
38 | if (unlikely(lt_before(new->priority, queued->priority))) { | ||
39 | /* pos is not less than new, thus insert here */ | ||
40 | __list_add(&new->wq.task_list, pos->prev, pos); | ||
41 | goto out; | ||
42 | } | ||
43 | passed++; | ||
44 | } | ||
45 | |||
46 | /* if we get to this point either the list is empty or every entry | ||
47 | * queued element is less than new. | ||
48 | * Let's add new to the end. */ | ||
49 | list_add_tail(&new->wq.task_list, &head->task_list); | ||
50 | out: | ||
51 | return passed; | ||
52 | } | ||
53 | |||
54 | #endif | ||
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index dfec80e351aa..a0f3ba54ed8f 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | 15 | ||
16 | #include <litmus/litmus.h> | 16 | #include <litmus/litmus.h> |
17 | #include <litmus/wait.h> | ||
17 | #include <litmus/jobs.h> | 18 | #include <litmus/jobs.h> |
18 | #include <litmus/sched_plugin.h> | 19 | #include <litmus/sched_plugin.h> |
19 | #include <litmus/edf_common.h> | 20 | #include <litmus/edf_common.h> |
diff --git a/litmus/sched_pfp.c b/litmus/sched_pfp.c index 45c838f1413e..af60bab563ca 100644 --- a/litmus/sched_pfp.c +++ b/litmus/sched_pfp.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | 13 | ||
14 | #include <litmus/litmus.h> | 14 | #include <litmus/litmus.h> |
15 | #include <litmus/wait.h> | ||
15 | #include <litmus/jobs.h> | 16 | #include <litmus/jobs.h> |
16 | #include <litmus/preempt.h> | 17 | #include <litmus/preempt.h> |
17 | #include <litmus/fp_common.h> | 18 | #include <litmus/fp_common.h> |
diff --git a/litmus/sched_psn_edf.c b/litmus/sched_psn_edf.c index 8e4a22dd8d6a..178ca0b33b04 100644 --- a/litmus/sched_psn_edf.c +++ b/litmus/sched_psn_edf.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | 16 | ||
17 | #include <litmus/litmus.h> | 17 | #include <litmus/litmus.h> |
18 | #include <litmus/wait.h> | ||
18 | #include <litmus/jobs.h> | 19 | #include <litmus/jobs.h> |
19 | #include <litmus/preempt.h> | 20 | #include <litmus/preempt.h> |
20 | #include <litmus/sched_plugin.h> | 21 | #include <litmus/sched_plugin.h> |