diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-08-20 16:49:50 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-09-21 12:26:12 -0400 |
commit | 7e13912f58908d302692bd8014b909d34eb16994 (patch) | |
tree | 5c28cafb5d2b2d0511bfe8370c6146063c16553e /litmus | |
parent | 9434d607f4ddaf2374dafd86c20ed4336230ecfa (diff) |
Improve readability of EDF comparisons.
Restructured the EDF task comparison code to improve readability.
Recoded chained logical expression embedded in return statement
into a series of if/else blocks.
Diffstat (limited to 'litmus')
-rw-r--r-- | litmus/edf_common.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/litmus/edf_common.c b/litmus/edf_common.c index 9b44dc2d8d1e..1ea0f31f35fb 100644 --- a/litmus/edf_common.c +++ b/litmus/edf_common.c | |||
@@ -63,25 +63,35 @@ int edf_higher_prio(struct task_struct* first, | |||
63 | 63 | ||
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | 66 | /* Determine the task with earliest deadline, with | |
67 | return !is_realtime(second_task) || | 67 | * tie-break logic. |
68 | 68 | */ | |
69 | /* is the deadline of the first task earlier? | 69 | if (unlikely(!is_realtime(second_task))) { |
70 | return 1; | ||
71 | } | ||
72 | else if (earlier_deadline(first_task, second_task)) { | ||
73 | /* Is the deadline of the first task earlier? | ||
70 | * Then it has higher priority. | 74 | * Then it has higher priority. |
71 | */ | 75 | */ |
72 | earlier_deadline(first_task, second_task) || | 76 | return 1; |
73 | 77 | } | |
74 | /* Do we have a deadline tie? | 78 | else if (get_deadline(first_task) == get_deadline(second_task)) { |
75 | * Then break by PID. | 79 | /* Need to tie break */ |
76 | */ | ||
77 | (get_deadline(first_task) == get_deadline(second_task) && | ||
78 | (first_task->pid < second_task->pid || | ||
79 | 80 | ||
80 | /* If the PIDs are the same then the task with the inherited | 81 | /* Tie break by pid */ |
81 | * priority wins. | 82 | if (first_task->pid < second_task->pid) { |
82 | */ | 83 | return 1; |
83 | (first_task->pid == second_task->pid && | 84 | } |
84 | !second->rt_param.inh_task))); | 85 | else if (first_task->pid == second_task->pid) { |
86 | /* If the PIDs are the same then the task with the | ||
87 | * inherited priority wins. | ||
88 | */ | ||
89 | if (!second->rt_param.inh_task) { | ||
90 | return 1; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | return 0; /* fall-through. prio(second_task) > prio(first_task) */ | ||
85 | } | 95 | } |
86 | 96 | ||
87 | int edf_ready_order(struct bheap_node* a, struct bheap_node* b) | 97 | int edf_ready_order(struct bheap_node* a, struct bheap_node* b) |