diff options
-rw-r--r-- | include/litmus.h | 30 | ||||
-rw-r--r-- | src/litmus.c | 72 |
2 files changed, 58 insertions, 44 deletions
diff --git a/include/litmus.h b/include/litmus.h index c2ca626..05f6d3c 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -47,10 +47,6 @@ typedef struct rt_param { | |||
47 | task_class_t cls; | 47 | task_class_t cls; |
48 | } rt_param_t; | 48 | } rt_param_t; |
49 | 49 | ||
50 | typedef int sema_id; /* ID of a semaphore in the Linux kernel */ | ||
51 | typedef int pi_sema_id; /* ID of a PI semaphore in the Linux kernel */ | ||
52 | typedef int srp_sema_id; /* ID of an SRP "semaphore" in the Linux kernel */ | ||
53 | |||
54 | typedef int pid_t; /* PID of a task */ | 50 | typedef int pid_t; /* PID of a task */ |
55 | 51 | ||
56 | /* X */ | 52 | /* X */ |
@@ -69,7 +65,6 @@ int set_rt_mode(int mode); | |||
69 | int set_rt_task_param(pid_t pid, rt_param_t* param); | 65 | int set_rt_task_param(pid_t pid, rt_param_t* param); |
70 | int get_rt_task_param(pid_t pid, rt_param_t* param); | 66 | int get_rt_task_param(pid_t pid, rt_param_t* param); |
71 | int prepare_rt_task(pid_t pid); | 67 | int prepare_rt_task(pid_t pid); |
72 | int sleep_next_period(void); | ||
73 | 68 | ||
74 | 69 | ||
75 | enum { | 70 | enum { |
@@ -79,18 +74,25 @@ enum { | |||
79 | int scheduler_setup(int cmd, void* param); | 74 | int scheduler_setup(int cmd, void* param); |
80 | 75 | ||
81 | 76 | ||
77 | /* file descriptor attached shared objects support */ | ||
78 | int od_open(int fd, int type, int obj_id); | ||
79 | int od_close(int od); | ||
82 | 80 | ||
83 | int pi_sema_init(void); | 81 | /* FMLP support */ |
84 | int pi_down(pi_sema_id sem_id); | 82 | int pi_down(int od); |
85 | int pi_up(pi_sema_id sem_id); | 83 | int pi_up(int od); |
86 | int pi_sema_free(pi_sema_id sem_id); | 84 | int srp_down(int od); |
87 | int srp_sema_init(void); | 85 | int srp_up(int od); |
88 | int srp_down(srp_sema_id sem_id); | 86 | int reg_task_srp_sem(int od); |
89 | int srp_up(srp_sema_id sem_id); | 87 | |
90 | int reg_task_srp_sem(srp_sema_id sem_id, pid_t t_pid); | 88 | /* job control*/ |
91 | int srp_sema_free(srp_sema_id sem_id); | ||
92 | int get_job_no(unsigned int* job_no); | 89 | int get_job_no(unsigned int* job_no); |
93 | int wait_for_job_release(unsigned int job_no); | 90 | int wait_for_job_release(unsigned int job_no); |
91 | int sleep_next_period(void); | ||
92 | |||
93 | |||
94 | |||
95 | |||
94 | 96 | ||
95 | /* library functions */ | 97 | /* library functions */ |
96 | void init_litmus(void); | 98 | void init_litmus(void); |
diff --git a/src/litmus.c b/src/litmus.c index 89f08cd..01acf73 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -1,13 +1,18 @@ | |||
1 | /* To get syscall() we need to define _GNU_SOURCE | ||
2 | * in modern glibc versions. | ||
3 | */ | ||
4 | #define _GNU_SOURCE | ||
5 | #include <unistd.h> | ||
1 | #include <stdlib.h> | 6 | #include <stdlib.h> |
2 | #include <stdio.h> | 7 | #include <stdio.h> |
3 | #include <string.h> | 8 | #include <string.h> |
4 | #include <sys/types.h> | 9 | #include <sys/types.h> |
5 | #include <unistd.h> | ||
6 | #include <errno.h> | 10 | #include <errno.h> |
7 | #include <signal.h> | 11 | #include <signal.h> |
8 | #include <sys/mman.h> | 12 | #include <sys/mman.h> |
9 | 13 | ||
10 | 14 | ||
15 | |||
11 | #include "litmus.h" | 16 | #include "litmus.h" |
12 | 17 | ||
13 | 18 | ||
@@ -32,6 +37,12 @@ type name(type1 arg1,type2 arg2) \ | |||
32 | return syscall(__NR_##name, arg1, arg2);\ | 37 | return syscall(__NR_##name, arg1, arg2);\ |
33 | } | 38 | } |
34 | 39 | ||
40 | #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ | ||
41 | type name(type1 arg1,type2 arg2, type3 arg3) \ | ||
42 | {\ | ||
43 | return syscall(__NR_##name, arg1, arg2, arg3); \ | ||
44 | } | ||
45 | |||
35 | 46 | ||
36 | /* clear the TID in the child */ | 47 | /* clear the TID in the child */ |
37 | #define CLONE_CHILD_CLEARTID 0x00200000 | 48 | #define CLONE_CHILD_CLEARTID 0x00200000 |
@@ -281,26 +292,27 @@ void init_litmus(void) | |||
281 | 292 | ||
282 | 293 | ||
283 | /* Litmus syscalls definitions */ | 294 | /* Litmus syscalls definitions */ |
284 | #define __NR_sched_getpolicy 321 | 295 | #define __NR_sched_setpolicy 320 |
285 | #define __NR_set_rt_mode 322 | 296 | #define __NR_sched_getpolicy 321 |
286 | #define __NR_set_rt_task_param 323 | 297 | #define __NR_set_rt_mode 322 |
287 | #define __NR_get_rt_task_param 324 | 298 | #define __NR_set_rt_task_param 323 |
288 | #define __NR_prepare_rt_task 325 | 299 | #define __NR_get_rt_task_param 324 |
289 | #define __NR_sleep_next_period 327 | 300 | #define __NR_prepare_rt_task 325 |
290 | #define __NR_scheduler_setup 328 | 301 | #define __NR_sleep_next_period 326 |
291 | #define __NR_register_np_flag 329 | 302 | #define __NR_scheduler_setup 327 |
292 | #define __NR_signal_exit_np 330 | 303 | #define __NR_register_np_flag 328 |
293 | #define __NR_pi_sema_init 331 | 304 | #define __NR_signal_exit_np 329 |
294 | #define __NR_pi_down 332 | 305 | #define __NR_od_open 330 |
295 | #define __NR_pi_up 333 | 306 | #define __NR_od_close 331 |
296 | #define __NR_pi_sema_free 334 | 307 | #define __NR_pi_down 332 |
297 | #define __NR_srp_sema_init 339 | 308 | #define __NR_pi_up 333 |
298 | #define __NR_srp_down 340 | 309 | #define __NR_srp_down 334 |
299 | #define __NR_srp_up 341 | 310 | #define __NR_srp_up 335 |
300 | #define __NR_reg_task_srp_sem 342 | 311 | #define __NR_reg_task_srp_sem 336 |
301 | #define __NR_srp_sema_free 343 | 312 | #define __NR_get_job_no 337 |
302 | #define __NR_get_job_no 344 | 313 | #define __NR_wait_for_job_release 338 |
303 | #define __NR_wait_for_job_release 345 | 314 | #define __NR_set_service_levels 339 |
315 | #define __NR_get_cur_service_level 340 | ||
304 | 316 | ||
305 | 317 | ||
306 | /* Syscall stub for setting RT mode and scheduling options */ | 318 | /* Syscall stub for setting RT mode and scheduling options */ |
@@ -313,15 +325,15 @@ _syscall0(int, sleep_next_period); | |||
313 | _syscall2(int, scheduler_setup, int, cmd, void*, param); | 325 | _syscall2(int, scheduler_setup, int, cmd, void*, param); |
314 | _syscall1(int, register_np_flag, struct np_flag*, flag); | 326 | _syscall1(int, register_np_flag, struct np_flag*, flag); |
315 | _syscall0(int, signal_exit_np); | 327 | _syscall0(int, signal_exit_np); |
316 | _syscall0(int, pi_sema_init); | 328 | |
317 | _syscall1(int, pi_down, pi_sema_id, sem_id); | 329 | _syscall3(int, od_open, int, fd, int, type, int, obj_id); |
318 | _syscall1(int, pi_up, pi_sema_id, sem_id); | 330 | _syscall1(int, od_close, int, od); |
319 | _syscall1(int, pi_sema_free, pi_sema_id, sem_id); | 331 | _syscall1(int, pi_down, int, od); |
320 | _syscall0(int, srp_sema_init); | 332 | _syscall1(int, pi_up, int, od); |
321 | _syscall1(int, srp_down, srp_sema_id, sem_id); | 333 | _syscall1(int, srp_down, int, od); |
322 | _syscall1(int, srp_up, srp_sema_id, sem_id); | 334 | _syscall1(int, srp_up, int, od); |
323 | _syscall2(int, reg_task_srp_sem, srp_sema_id, sem_id, pid_t, t_pid); | 335 | _syscall1(int, reg_task_srp_sem, int, od); |
324 | _syscall1(int, srp_sema_free, srp_sema_id, sem_id); | 336 | |
325 | _syscall1(int, get_job_no, unsigned int*, job_no); | 337 | _syscall1(int, get_job_no, unsigned int*, job_no); |
326 | _syscall1(int, wait_for_job_release, unsigned int, job_no); | 338 | _syscall1(int, wait_for_job_release, unsigned int, job_no); |
327 | 339 | ||