diff options
Diffstat (limited to 'litmus/edzl_common.c')
| -rw-r--r-- | litmus/edzl_common.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/litmus/edzl_common.c b/litmus/edzl_common.c new file mode 100644 index 000000000000..9e26304a1ea2 --- /dev/null +++ b/litmus/edzl_common.c | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | /* | ||
| 2 | * kernel/edzl_common.c | ||
| 3 | * | ||
| 4 | * Common functions for EDZL based scheduler. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <linux/percpu.h> | ||
| 8 | #include <linux/sched.h> | ||
| 9 | #include <linux/list.h> | ||
| 10 | |||
| 11 | #include <litmus/litmus.h> | ||
| 12 | #include <litmus/sched_plugin.h> | ||
| 13 | #include <litmus/sched_trace.h> | ||
| 14 | |||
| 15 | #include <litmus/edf_common.h> | ||
| 16 | #include <litmus/edzl_common.h> | ||
| 17 | |||
| 18 | |||
| 19 | int edzl_higher_prio(struct task_struct* first, | ||
| 20 | struct task_struct* second) | ||
| 21 | { | ||
| 22 | struct task_struct *first_task = first; | ||
| 23 | struct task_struct *second_task = second; | ||
| 24 | |||
| 25 | /* There is no point in comparing a task to itself. */ | ||
| 26 | if (first && first == second) { | ||
| 27 | TRACE_TASK(first, | ||
| 28 | "WARNING: pointless edf priority comparison.\n"); | ||
| 29 | return 0; | ||
| 30 | } | ||
| 31 | |||
| 32 | |||
| 33 | /* Check for inherited priorities. Change task | ||
| 34 | * used for comparison in such a case. | ||
| 35 | */ | ||
| 36 | if (first && first->rt_param.inh_task) | ||
| 37 | first_task = first->rt_param.inh_task; | ||
| 38 | if (second && second->rt_param.inh_task) | ||
| 39 | second_task = second->rt_param.inh_task; | ||
| 40 | |||
| 41 | /* null checks & rt checks */ | ||
| 42 | if(!first_task) | ||
| 43 | return 0; | ||
| 44 | else if(!second_task || !is_realtime(second_task)) | ||
| 45 | return 1; | ||
| 46 | |||
| 47 | |||
| 48 | if(likely(get_zerolaxity(first_task) == get_zerolaxity(second_task))) | ||
| 49 | { | ||
| 50 | /* edf order if both tasks have the same laxity state */ | ||
| 51 | return(edf_higher_prio(first_task, second_task)); | ||
| 52 | } | ||
| 53 | else | ||
| 54 | { | ||
| 55 | return(get_zerolaxity(first_task)); | ||
| 56 | } | ||
| 57 | } | ||
