aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-08-20 16:49:50 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2012-08-20 16:49:50 -0400
commit9a19f35c9c287cb8abd5bcf276ae8d1a3e876907 (patch)
tree983aa79d10e4b170b1a533183d5d414f2c491290
parentb53c479a0f44b8990ce106622412a3bf54809944 (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.
-rw-r--r--litmus/edf_common.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/litmus/edf_common.c b/litmus/edf_common.c
index 9b44dc2d8d1e..668737f0fbf9 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_task->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
87int edf_ready_order(struct bheap_node* a, struct bheap_node* b) 97int edf_ready_order(struct bheap_node* a, struct bheap_node* b)