aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2013-03-13 15:33:57 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2013-03-13 15:33:57 -0400
commit944a78c21028da69fb53c0aec3e9dfdb048d47e4 (patch)
treebdbc77b3c0ff1337670a7e5d0f9d438388c1a866 /src
parentf338b34ea0fb6136ea3895a07161ece030c4b998 (diff)
parent1ff4fc699f01f0ad1359fad48b00c9d3be1b28b4 (diff)
Merge branch 'gh/staging' into temp
Conflicts: Makefile bin/rt_launch.c bin/rtspin.c src/task.c
Diffstat (limited to 'src')
-rw-r--r--src/kernel_iface.c15
-rw-r--r--src/litmus.c62
-rw-r--r--src/signal.c2
-rw-r--r--src/task.c12
4 files changed, 57 insertions, 34 deletions
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index 4cc1af5..e446102 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -56,9 +56,8 @@ ssize_t read_file(const char* fname, void* buf, size_t maxlen)
56 return got; 56 return got;
57} 57}
58 58
59int get_nr_ts_release_waiters(void) 59int read_litmus_stats(int *ready, int *all)
60{ 60{
61 int ready = 0, all = 0;
62 char buf[100]; 61 char buf[100];
63 ssize_t len; 62 ssize_t len;
64 63
@@ -67,11 +66,17 @@ int get_nr_ts_release_waiters(void)
67 len = sscanf(buf, 66 len = sscanf(buf,
68 "real-time tasks = %d\n" 67 "real-time tasks = %d\n"
69 "ready for release = %d\n", 68 "ready for release = %d\n",
70 &all, &ready); 69 all, ready);
71 if (len == 2) 70 return len == 2;
71}
72
73int get_nr_ts_release_waiters(void)
74{
75 int ready, all;
76 if (read_litmus_stats(&ready, &all))
72 return ready; 77 return ready;
73 else 78 else
74 return len; 79 return -1;
75} 80}
76 81
77/* thread-local pointer to control page */ 82/* thread-local pointer to control page */
diff --git a/src/litmus.c b/src/litmus.c
index ba47e45..7cdffcc 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -3,7 +3,10 @@
3#include <stdio.h> 3#include <stdio.h>
4#include <string.h> 4#include <string.h>
5#include <signal.h> 5#include <signal.h>
6#include <fcntl.h>
6#include <sys/mman.h> 7#include <sys/mman.h>
8#include <sys/types.h>
9
7 10
8#include <sched.h> /* for cpu sets */ 11#include <sched.h> /* for cpu sets */
9 12
@@ -32,7 +35,7 @@ static struct {
32 {IKGLP_GPU_AFF_OBS, "IKGLP-GPU"}, 35 {IKGLP_GPU_AFF_OBS, "IKGLP-GPU"},
33 {KFMLP_SIMPLE_GPU_AFF_OBS, "KFMLP-GPU-SIMPLE"}, 36 {KFMLP_SIMPLE_GPU_AFF_OBS, "KFMLP-GPU-SIMPLE"},
34 {KFMLP_GPU_AFF_OBS, "KFMLP-GPU"}, 37 {KFMLP_GPU_AFF_OBS, "KFMLP-GPU"},
35 38
36 {PRIOQ_MUTEX, "PRIOQ"}, 39 {PRIOQ_MUTEX, "PRIOQ"},
37}; 40};
38 41
@@ -60,6 +63,23 @@ const char* name_for_lock_protocol(int id)
60 return "<UNKNOWN>"; 63 return "<UNKNOWN>";
61} 64}
62 65
66int litmus_open_lock(
67 obj_type_t protocol,
68 int lock_id,
69 const char* namespace,
70 void *config_param)
71{
72 int fd, od;
73
74 fd = open(namespace, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
75 if (fd < 0)
76 return -1;
77 od = od_openx(fd, protocol, lock_id, config_param);
78 close(fd);
79 return od;
80}
81
82
63 83
64void show_rt_param(struct rt_task* tp) 84void show_rt_param(struct rt_task* tp)
65{ 85{
@@ -171,7 +191,7 @@ int open_kfmlp_gpu_sem(int fd, int name,
171 unsigned int num_replicas; 191 unsigned int num_replicas;
172 struct gpu_affinity_observer_args aff_args; 192 struct gpu_affinity_observer_args aff_args;
173 int aff_type; 193 int aff_type;
174 194
175 // number of GPU tokens 195 // number of GPU tokens
176 num_replicas = num_gpus * rho; 196 num_replicas = num_gpus * rho;
177 197
@@ -181,20 +201,20 @@ int open_kfmlp_gpu_sem(int fd, int name,
181 perror("open_kfmlp_sem"); 201 perror("open_kfmlp_sem");
182 return -1; 202 return -1;
183 } 203 }
184 204
185 // create the affinity method to use. 205 // create the affinity method to use.
186 // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS 206 // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS
187 aff_args.obs.lock_od = lock_od; 207 aff_args.obs.lock_od = lock_od;
188 aff_args.replica_to_gpu_offset = gpu_offset; 208 aff_args.replica_to_gpu_offset = gpu_offset;
189 aff_args.rho = rho; 209 aff_args.rho = rho;
190 210
191 aff_type = (affinity_aware) ? KFMLP_GPU_AFF_OBS : KFMLP_SIMPLE_GPU_AFF_OBS; 211 aff_type = (affinity_aware) ? KFMLP_GPU_AFF_OBS : KFMLP_SIMPLE_GPU_AFF_OBS;
192 affinity_od = od_openx(fd, aff_type, name+1, &aff_args); 212 affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
193 if(affinity_od < 0) { 213 if(affinity_od < 0) {
194 perror("open_kfmlp_aff"); 214 perror("open_kfmlp_aff");
195 return -1; 215 return -1;
196 } 216 }
197 217
198 return lock_od; 218 return lock_od;
199} 219}
200 220
@@ -209,28 +229,28 @@ int open_kfmlp_gpu_sem(int fd, int name,
209// 229//
210// // number of GPU tokens 230// // number of GPU tokens
211// num_replicas = num_gpus * num_simult_users; 231// num_replicas = num_gpus * num_simult_users;
212// 232//
213// // create the GPU token lock 233// // create the GPU token lock
214// lock_od = open_ikglp_sem(fd, name, (void*)&num_replicas); 234// lock_od = open_ikglp_sem(fd, name, (void*)&num_replicas);
215// if(lock_od < 0) { 235// if(lock_od < 0) {
216// perror("open_ikglp_sem"); 236// perror("open_ikglp_sem");
217// return -1; 237// return -1;
218// } 238// }
219// 239//
220// // create the affinity method to use. 240// // create the affinity method to use.
221// // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS 241// // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS
222// aff_args.obs.lock_od = lock_od; 242// aff_args.obs.lock_od = lock_od;
223// aff_args.replica_to_gpu_offset = gpu_offset; 243// aff_args.replica_to_gpu_offset = gpu_offset;
224// aff_args.nr_simult_users = num_simult_users; 244// aff_args.nr_simult_users = num_simult_users;
225// aff_args.relaxed_rules = (relax_max_fifo_len) ? 1 : 0; 245// aff_args.relaxed_rules = (relax_max_fifo_len) ? 1 : 0;
226// 246//
227// aff_type = (affinity_aware) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS; 247// aff_type = (affinity_aware) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS;
228// affinity_od = od_openx(fd, aff_type, name+1, &aff_args); 248// affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
229// if(affinity_od < 0) { 249// if(affinity_od < 0) {
230// perror("open_ikglp_aff"); 250// perror("open_ikglp_aff");
231// return -1; 251// return -1;
232// } 252// }
233// 253//
234// return lock_od; 254// return lock_od;
235//} 255//}
236 256
@@ -243,7 +263,7 @@ int open_ikglp_sem(int fd, int name, unsigned int nr_replicas)
243 .nr_replicas = nr_replicas, 263 .nr_replicas = nr_replicas,
244 .max_in_fifos = IKGLP_M_IN_FIFOS, 264 .max_in_fifos = IKGLP_M_IN_FIFOS,
245 .max_fifo_len = IKGLP_OPTIMAL_FIFO_LEN}; 265 .max_fifo_len = IKGLP_OPTIMAL_FIFO_LEN};
246 266
247 return od_openx(fd, IKGLP_SEM, name, &args); 267 return od_openx(fd, IKGLP_SEM, name, &args);
248} 268}
249 269
@@ -257,7 +277,7 @@ int open_gpusync_token_lock(int fd, int name,
257{ 277{
258 int lock_od; 278 int lock_od;
259 int affinity_od; 279 int affinity_od;
260 280
261 struct ikglp_args args = { 281 struct ikglp_args args = {
262 .nr_replicas = num_gpus*rho, 282 .nr_replicas = num_gpus*rho,
263 .max_in_fifos = max_in_fifos, 283 .max_in_fifos = max_in_fifos,
@@ -265,41 +285,37 @@ int open_gpusync_token_lock(int fd, int name,
265 }; 285 };
266 struct gpu_affinity_observer_args aff_args; 286 struct gpu_affinity_observer_args aff_args;
267 int aff_type; 287 int aff_type;
268 288
269 if (!num_gpus || !rho) { 289 if (!num_gpus || !rho) {
270 perror("open_gpusync_sem"); 290 perror("open_gpusync_sem");
271 return -1; 291 return -1;
272 } 292 }
273 293
274 if ((max_in_fifos != IKGLP_UNLIMITED_IN_FIFOS) && 294 if ((max_in_fifos != IKGLP_UNLIMITED_IN_FIFOS) &&
275 (max_fifo_len != IKGLP_UNLIMITED_FIFO_LEN) && 295 (max_fifo_len != IKGLP_UNLIMITED_FIFO_LEN) &&
276 (max_in_fifos > args.nr_replicas * max_fifo_len)) { 296 (max_in_fifos > args.nr_replicas * max_fifo_len)) {
277 perror("open_gpusync_sem"); 297 perror("open_gpusync_sem");
278 return(-1); 298 return(-1);
279 } 299 }
280 300
281 lock_od = od_openx(fd, IKGLP_SEM, name, &args); 301 lock_od = od_openx(fd, IKGLP_SEM, name, &args);
282 if(lock_od < 0) { 302 if(lock_od < 0) {
283 perror("open_gpusync_sem"); 303 perror("open_gpusync_sem");
284 return -1; 304 return -1;
285 } 305 }
286 306
287 // create the affinity method to use. 307 // create the affinity method to use.
288 aff_args.obs.lock_od = lock_od; 308 aff_args.obs.lock_od = lock_od;
289 aff_args.replica_to_gpu_offset = gpu_offset; 309 aff_args.replica_to_gpu_offset = gpu_offset;
290 aff_args.rho = rho; 310 aff_args.rho = rho;
291 aff_args.relaxed_rules = (max_fifo_len == IKGLP_UNLIMITED_FIFO_LEN) ? 1 : 0; 311 aff_args.relaxed_rules = (max_fifo_len == IKGLP_UNLIMITED_FIFO_LEN) ? 1 : 0;
292 312
293 aff_type = (enable_affinity_heuristics) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS; 313 aff_type = (enable_affinity_heuristics) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS;
294 affinity_od = od_openx(fd, aff_type, name+1, &aff_args); 314 affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
295 if(affinity_od < 0) { 315 if(affinity_od < 0) {
296 perror("open_gpusync_affinity"); 316 perror("open_gpusync_affinity");
297 return -1; 317 return -1;
298 } 318 }
299 319
300 return lock_od; 320 return lock_od;
301} 321}
302
303
304
305
diff --git a/src/signal.c b/src/signal.c
index bfe18b9..397a797 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -28,7 +28,7 @@ static void reg_litmus_signals(unsigned long litmus_sig_mask,
28{ 28{
29 int ret; 29 int ret;
30 30
31 if (litmus_sig_mask | SIG_BUDGET_MASK) { 31 if (litmus_sig_mask | SIG_BUDGET_MASK) {
32 ret = sigaction(SIG_BUDGET, pAction, NULL); 32 ret = sigaction(SIG_BUDGET, pAction, NULL);
33 check("SIG_BUDGET"); 33 check("SIG_BUDGET");
34 } 34 }
diff --git a/src/task.c b/src/task.c
index 26fc15a..9317cc7 100644
--- a/src/task.c
+++ b/src/task.c
@@ -40,15 +40,16 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup,
40 return rt_task; 40 return rt_task;
41} 41}
42 42
43int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, 43int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, lt_t wcet, lt_t period,
44 task_class_t rt_class) 44 unsigned int priority, task_class_t cls)
45{ 45{
46 struct rt_task params; 46 struct rt_task params;
47 params.cpu = cpu; 47 params.cpu = cpu;
48 params.period = period; 48 params.period = period;
49 params.exec_cost = wcet; 49 params.exec_cost = wcet;
50 params.cls = rt_class; 50 params.cls = cls;
51 params.phase = 0; 51 params.phase = 0;
52 params.priority = priority;
52 /* enforce budget for tasks that might not use sleep_next_period() */ 53 /* enforce budget for tasks that might not use sleep_next_period() */
53 params.budget_policy = QUANTUM_ENFORCEMENT; 54 params.budget_policy = QUANTUM_ENFORCEMENT;
54 55
@@ -56,8 +57,9 @@ int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period,
56 (rt_setup_fn_t) set_rt_task_param, &params); 57 (rt_setup_fn_t) set_rt_task_param, &params);
57} 58}
58 59
59int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period) { 60int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, lt_t wcet, lt_t period,
60 return __create_rt_task(rt_prog, arg, cpu, wcet, period, RT_CLASS_HARD); 61 unsigned int priority) {
62 return __create_rt_task(rt_prog, arg, cpu, wcet, period, priority, RT_CLASS_HARD);
61} 63}
62 64
63 65