diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/litmus.c | 32 | ||||
-rw-r--r-- | src/task.c | 5 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/litmus.c b/src/litmus.c index b0416c4..f7c91de 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -39,6 +39,33 @@ int be_migrate_to(int target_cpu) | |||
39 | return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); | 39 | return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); |
40 | } | 40 | } |
41 | 41 | ||
42 | static unsigned int compute_pfair_deadline(lt_t wt_num, lt_t wt_den) | ||
43 | { | ||
44 | int dead; | ||
45 | dead = wt_den / wt_num; | ||
46 | if (wt_den % wt_num > 0) | ||
47 | dead++; | ||
48 | return dead; | ||
49 | } | ||
50 | |||
51 | unsigned int compute_initial_cpu_edfos(lt_t fracs[][2]) | ||
52 | { | ||
53 | int initial_cpu = -1; | ||
54 | int lowest_deadline = UINT_MAX; | ||
55 | int current_deadline, i; | ||
56 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { | ||
57 | if (fracs[i][0] > 0) { | ||
58 | current_deadline = compute_pfair_deadline(fracs[i][0], | ||
59 | fracs[i][1]); | ||
60 | if (current_deadline < lowest_deadline) { | ||
61 | lowest_deadline = current_deadline; | ||
62 | initial_cpu = i; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | return initial_cpu; | ||
67 | } | ||
68 | |||
42 | int sporadic_task(lt_t e, lt_t p, lt_t phase, | 69 | int sporadic_task(lt_t e, lt_t p, lt_t phase, |
43 | int cpu, task_class_t cls, | 70 | int cpu, task_class_t cls, |
44 | budget_policy_t budget_policy, int set_cpu_set) | 71 | budget_policy_t budget_policy, int set_cpu_set) |
@@ -107,7 +134,7 @@ int sporadic_task_ns_edffm(lt_t e, lt_t p, lt_t phase, int cpu, | |||
107 | return set_rt_task_param(gettid(), ¶m); | 134 | return set_rt_task_param(gettid(), ¶m); |
108 | } | 135 | } |
109 | 136 | ||
110 | int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, | 137 | int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, int cpu, |
111 | lt_t fracs[][2], task_class_t cls, | 138 | lt_t fracs[][2], task_class_t cls, |
112 | budget_policy_t budget_policy) | 139 | budget_policy_t budget_policy) |
113 | { | 140 | { |
@@ -118,7 +145,8 @@ int sporadic_task_ns_edfos(lt_t e, lt_t p, lt_t phase, | |||
118 | os.first_cpu = UINT_MAX; | 145 | os.first_cpu = UINT_MAX; |
119 | param.exec_cost = e; | 146 | param.exec_cost = e; |
120 | param.period = p; | 147 | param.period = p; |
121 | for (i = 0; i < NR_CPUS; i++) { | 148 | param.cpu = cpu; |
149 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { | ||
122 | if (fracs[i][0] > 0) { | 150 | if (fracs[i][0] > 0) { |
123 | os.migrat++; | 151 | os.migrat++; |
124 | if (os.first_cpu == UINT_MAX) | 152 | if (os.first_cpu == UINT_MAX) |
@@ -71,12 +71,13 @@ int __create_rt_task_edffm(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | |||
71 | (rt_setup_fn_t) set_rt_task_param, ¶ms); | 71 | (rt_setup_fn_t) set_rt_task_param, ¶ms); |
72 | } | 72 | } |
73 | 73 | ||
74 | int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int wcet, | 74 | int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int cpu, int wcet, |
75 | int period, lt_t fracs[][2], task_class_t class) | 75 | int period, lt_t fracs[][2], task_class_t class) |
76 | { | 76 | { |
77 | struct rt_task params; | 77 | struct rt_task params; |
78 | struct edfos_params os; | 78 | struct edfos_params os; |
79 | int i; | 79 | int i; |
80 | params.cpu = cpu; | ||
80 | params.period = period; | 81 | params.period = period; |
81 | params.exec_cost = wcet; | 82 | params.exec_cost = wcet; |
82 | params.cls = class; | 83 | params.cls = class; |
@@ -86,7 +87,7 @@ int __create_rt_task_edfos(rt_fn_t rt_prog, void *arg, int wcet, | |||
86 | 87 | ||
87 | os.migrat = 0; | 88 | os.migrat = 0; |
88 | os.first_cpu = UINT_MAX; | 89 | os.first_cpu = UINT_MAX; |
89 | for (i = 0; i < NR_CPUS; i++) { | 90 | for (i = 0; i < NR_CPUS_EDF_OS; i++) { |
90 | if (fracs[i][0] > 0) { | 91 | if (fracs[i][0] > 0) { |
91 | os.migrat++; | 92 | os.migrat++; |
92 | if (os.first_cpu == UINT_MAX) | 93 | if (os.first_cpu == UINT_MAX) |