diff options
Diffstat (limited to 'litmus/fifo_common.c')
-rw-r--r-- | litmus/fifo_common.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/litmus/fifo_common.c b/litmus/fifo_common.c new file mode 100644 index 000000000000..84ae98e42ae4 --- /dev/null +++ b/litmus/fifo_common.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * kernel/edf_common.c | ||
3 | * | ||
4 | * Common functions for EDF 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/fifo_common.h> | ||
16 | |||
17 | int fifo_higher_prio(struct task_struct* first, | ||
18 | struct task_struct* second) | ||
19 | { | ||
20 | /* There is no point in comparing a task to itself. */ | ||
21 | if (first && first == second) { | ||
22 | TRACE_TASK(first, | ||
23 | "WARNING: pointless fifo priority comparison.\n"); | ||
24 | BUG_ON(1); | ||
25 | return 0; | ||
26 | } | ||
27 | |||
28 | if (!first || !second) | ||
29 | return first && !second; | ||
30 | |||
31 | /* Tiebreak by PID */ | ||
32 | return (get_release(first) == get_release(second) && | ||
33 | first->pid > second->pid) || | ||
34 | (get_release(first) < get_release(second)); | ||
35 | |||
36 | |||
37 | } | ||
38 | |||
39 | int fifo_ready_order(struct bheap_node* a, struct bheap_node* b) | ||
40 | { | ||
41 | return fifo_higher_prio(bheap2task(a), bheap2task(b)); | ||
42 | } | ||
43 | |||
44 | void fifo_domain_init(rt_domain_t* rt, check_resched_needed_t resched, | ||
45 | release_jobs_t release) | ||
46 | { | ||
47 | rt_domain_init(rt, fifo_ready_order, resched, release); | ||
48 | } | ||
49 | |||
50 | int fifo_preemption_needed(rt_domain_t* rt, struct task_struct *t) | ||
51 | { | ||
52 | if (!__jobs_pending(rt)) | ||
53 | return 0; | ||
54 | if (!t) | ||
55 | return 1; | ||
56 | |||
57 | return !is_realtime(t) || fifo_higher_prio(__next_ready(rt), t); | ||
58 | } | ||