diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-27 18:16:26 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-27 18:16:26 -0400 |
commit | d4ef04e8b213df75e567ae4a78ba510d0d3e492a (patch) | |
tree | 461129f8e594cf2368802eb9bd703c5565ba122f | |
parent | 76f8ba0ab085c5f5c4121462a0a237e205c3e51c (diff) |
Litmus core: support tie-breaking in priority queue
We'd like to have consistent deadline tie-breaking
in priority-ordered wait queues, too.
-rw-r--r-- | include/litmus/wait.h | 15 | ||||
-rw-r--r-- | litmus/locking.c | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/include/litmus/wait.h b/include/litmus/wait.h index ab3770904b1f..ce1347c355f8 100644 --- a/include/litmus/wait.h +++ b/include/litmus/wait.h | |||
@@ -9,6 +9,8 @@ struct __prio_wait_queue { | |||
9 | 9 | ||
10 | /* some priority point */ | 10 | /* some priority point */ |
11 | lt_t priority; | 11 | lt_t priority; |
12 | /* break ties in priority by lower tie_breaker */ | ||
13 | unsigned int tie_breaker; | ||
12 | }; | 14 | }; |
13 | 15 | ||
14 | typedef struct __prio_wait_queue prio_wait_queue_t; | 16 | typedef struct __prio_wait_queue prio_wait_queue_t; |
@@ -18,7 +20,18 @@ static inline void init_prio_waitqueue_entry(prio_wait_queue_t *pwq, | |||
18 | lt_t priority) | 20 | lt_t priority) |
19 | { | 21 | { |
20 | init_waitqueue_entry(&pwq->wq, t); | 22 | init_waitqueue_entry(&pwq->wq, t); |
21 | pwq->priority = priority; | 23 | pwq->priority = priority; |
24 | pwq->tie_breaker = 0; | ||
25 | } | ||
26 | |||
27 | static inline void init_prio_waitqueue_entry_tie(prio_wait_queue_t *pwq, | ||
28 | struct task_struct* t, | ||
29 | lt_t priority, | ||
30 | unsigned int tie_breaker) | ||
31 | { | ||
32 | init_waitqueue_entry(&pwq->wq, t); | ||
33 | pwq->priority = priority; | ||
34 | pwq->tie_breaker = tie_breaker; | ||
22 | } | 35 | } |
23 | 36 | ||
24 | unsigned int __add_wait_queue_prio_exclusive( | 37 | unsigned int __add_wait_queue_prio_exclusive( |
diff --git a/litmus/locking.c b/litmus/locking.c index 6ceaf2e9d0a2..2db2c2813c0b 100644 --- a/litmus/locking.c +++ b/litmus/locking.c | |||
@@ -152,7 +152,9 @@ unsigned int __add_wait_queue_prio_exclusive( | |||
152 | prio_wait_queue_t* queued = list_entry(pos, prio_wait_queue_t, | 152 | prio_wait_queue_t* queued = list_entry(pos, prio_wait_queue_t, |
153 | wq.task_list); | 153 | wq.task_list); |
154 | 154 | ||
155 | if (unlikely(lt_before(new->priority, queued->priority))) { | 155 | if (unlikely(lt_before(new->priority, queued->priority) || |
156 | (new->priority == queued->priority && | ||
157 | new->tie_breaker < queued->tie_breaker))) { | ||
156 | /* pos is not less than new, thus insert here */ | 158 | /* pos is not less than new, thus insert here */ |
157 | __list_add(&new->wq.task_list, pos->prev, pos); | 159 | __list_add(&new->wq.task_list, pos->prev, pos); |
158 | goto out; | 160 | goto out; |