diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-09-06 08:34:37 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-10-18 16:14:08 -0400 |
commit | 3e4922fc06e0c3a377ef3c92982ee3798d769474 (patch) | |
tree | b64e15ac94d943121bfd49036e4dcad2f6160b62 | |
parent | a5797a7ff1bec0600d78120b269adfe565432fc8 (diff) |
P-FP: simplify priority comparison
Make the priority comparison easier to read. Also, remove the "equal
PID" clause and insert a corresponding BUG_ON() instead; this should
really never happen.
-rw-r--r-- | litmus/fp_common.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/litmus/fp_common.c b/litmus/fp_common.c index 31fc2db20adf..964a4729deff 100644 --- a/litmus/fp_common.c +++ b/litmus/fp_common.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <litmus/fp_common.h> | 15 | #include <litmus/fp_common.h> |
16 | 16 | ||
17 | /* fp_higher_prio - returns true if first has a higher static priority | 17 | /* fp_higher_prio - returns true if first has a higher static priority |
18 | * than second. Deadline ties are broken by PID. | 18 | * than second. Ties are broken by PID. |
19 | * | 19 | * |
20 | * both first and second may be NULL | 20 | * both first and second may be NULL |
21 | */ | 21 | */ |
@@ -37,6 +37,9 @@ int fp_higher_prio(struct task_struct* first, | |||
37 | if (!first || !second) | 37 | if (!first || !second) |
38 | return first && !second; | 38 | return first && !second; |
39 | 39 | ||
40 | if (!is_realtime(second_task)) | ||
41 | return 1; | ||
42 | |||
40 | #ifdef CONFIG_LITMUS_LOCKING | 43 | #ifdef CONFIG_LITMUS_LOCKING |
41 | 44 | ||
42 | /* Check for inherited priorities. Change task | 45 | /* Check for inherited priorities. Change task |
@@ -51,33 +54,30 @@ int fp_higher_prio(struct task_struct* first, | |||
51 | */ | 54 | */ |
52 | if (unlikely(is_priority_boosted(first_task))) { | 55 | if (unlikely(is_priority_boosted(first_task))) { |
53 | /* first_task is boosted, how about second_task? */ | 56 | /* first_task is boosted, how about second_task? */ |
54 | if (!is_priority_boosted(second_task) || | 57 | if (is_priority_boosted(second_task)) |
55 | lt_before(get_boost_start(first_task), | 58 | /* break by priority point */ |
56 | get_boost_start(second_task))) | 59 | return lt_before(get_boost_start(first_task), |
57 | return 1; | 60 | get_boost_start(second_task)); |
58 | else | 61 | else |
59 | return 0; | 62 | /* priority boosting wins. */ |
63 | return 1; | ||
60 | } else if (unlikely(is_priority_boosted(second_task))) | 64 | } else if (unlikely(is_priority_boosted(second_task))) |
61 | /* second_task is boosted, first is not*/ | 65 | /* second_task is boosted, first is not*/ |
62 | return 0; | 66 | return 0; |
63 | 67 | ||
64 | #endif | 68 | #endif |
65 | 69 | ||
70 | /* Comparisons to itself are not expected; priority inheritance | ||
71 | * should also not cause this to happen. */ | ||
72 | BUG_ON(first_task == second_task); | ||
66 | 73 | ||
67 | return !is_realtime(second_task) || | 74 | if (get_priority(first_task) < get_priority(second_task)) |
68 | 75 | return 1; | |
69 | get_priority(first_task) < get_priority(second_task) || | 76 | else if (get_priority(first_task) == get_priority(second_task)) |
70 | 77 | /* Break by PID. */ | |
71 | /* Break by PID. | 78 | return first_task->pid < second_task->pid; |
72 | */ | 79 | else |
73 | (get_priority(first_task) == get_priority(second_task) && | 80 | return 0; |
74 | (first_task->pid < second_task->pid || | ||
75 | |||
76 | /* If the PIDs are the same then the task with the inherited | ||
77 | * priority wins. | ||
78 | */ | ||
79 | (first_task->pid == second_task->pid && | ||
80 | !second->rt_param.inh_task))); | ||
81 | } | 81 | } |
82 | 82 | ||
83 | int fp_ready_order(struct bheap_node* a, struct bheap_node* b) | 83 | int fp_ready_order(struct bheap_node* a, struct bheap_node* b) |