diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-08-23 16:57:26 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-08-23 16:57:26 -0400 |
commit | e77f6c0cdd2559502a80dc7f2e60e6cdc00a3bf6 (patch) | |
tree | 7701653e0fb851dab9cebf16c13a03cf4c698e81 | |
parent | f4f203df92abc8f3ff16b3aea00e3876c2030ec9 (diff) |
added new test
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | litmus.c | 4 | ||||
-rw-r--r-- | wait_test.c | 102 |
3 files changed, 109 insertions, 4 deletions
@@ -2,10 +2,13 @@ CFLAGS=-Wall -g | |||
2 | CPPFLAGS=-Wall -g | 2 | CPPFLAGS=-Wall -g |
3 | 3 | ||
4 | 4 | ||
5 | all: showsched iotest set_rt_mode run timeout rt_launch edfhsb liblitmus.a | 5 | all: showsched iotest set_rt_mode run timeout rt_launch edfhsb liblitmus.a wait_test |
6 | 6 | ||
7 | clean: | 7 | clean: |
8 | rm *.o showsched iotest set_rt_mode run timeout rt_launch edfhsb liblitmus.a | 8 | rm *.o showsched iotest set_rt_mode run timeout rt_launch edfhsb liblitmus.a wait_test |
9 | |||
10 | wait_test: wait_test.o litmus.h litmus.o | ||
11 | cc -static -o wait_test litmus.o wait_test.o | ||
9 | 12 | ||
10 | iotest: iotest.o litmus.h litmus.o | 13 | iotest: iotest.o litmus.h litmus.o |
11 | cc -static -o iotest litmus.o iotest.o | 14 | cc -static -o iotest litmus.o iotest.o |
@@ -195,7 +195,7 @@ task_class_t str2class(const char* str) | |||
195 | #define __NR_srp_up 341 | 195 | #define __NR_srp_up 341 |
196 | #define __NR_reg_task_srp_sem 342 | 196 | #define __NR_reg_task_srp_sem 342 |
197 | #define __NR_srp_sema_free 343 | 197 | #define __NR_srp_sema_free 343 |
198 | #define __NR_query_job_no 344 | 198 | #define __NR_get_job_no 344 |
199 | #define __NR_wait_for_job_release 345 | 199 | #define __NR_wait_for_job_release 345 |
200 | 200 | ||
201 | 201 | ||
@@ -224,6 +224,6 @@ _syscall1(int, srp_down, srp_sema_id, sem_id); | |||
224 | _syscall1(int, srp_up, srp_sema_id, sem_id); | 224 | _syscall1(int, srp_up, srp_sema_id, sem_id); |
225 | _syscall2(int, reg_task_srp_sem, srp_sema_id, sem_id, pid_t, t_pid); | 225 | _syscall2(int, reg_task_srp_sem, srp_sema_id, sem_id, pid_t, t_pid); |
226 | _syscall1(int, srp_sema_free, srp_sema_id, sem_id); | 226 | _syscall1(int, srp_sema_free, srp_sema_id, sem_id); |
227 | _syscall1(int, query_job_no, unsigned int*, job_no); | 227 | _syscall1(int, get_job_no, unsigned int*, job_no); |
228 | _syscall1(int, wait_for_job_release, unsigned int, job_no); | 228 | _syscall1(int, wait_for_job_release, unsigned int, job_no); |
229 | 229 | ||
diff --git a/wait_test.c b/wait_test.c new file mode 100644 index 0000000..0ac6a4f --- /dev/null +++ b/wait_test.c | |||
@@ -0,0 +1,102 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <signal.h> | ||
4 | #include <unistd.h> | ||
5 | #include <sys/time.h> | ||
6 | #include <sys/wait.h> | ||
7 | #include <sys/types.h> | ||
8 | #include <sys/stat.h> | ||
9 | #include <fcntl.h> | ||
10 | |||
11 | #include "litmus.h" | ||
12 | |||
13 | #define US_PER_MS 1000 | ||
14 | |||
15 | #define NUMTASKS 4 | ||
16 | |||
17 | int prefix(void) | ||
18 | { | ||
19 | char field[1024]; | ||
20 | int prefix[1024]; | ||
21 | int i, sum = 0; | ||
22 | |||
23 | for (i = 0; i < 1024; i++) { | ||
24 | sum += field[i]; | ||
25 | prefix[i] = sum; | ||
26 | } | ||
27 | return sum; | ||
28 | } | ||
29 | |||
30 | |||
31 | void do_stuff(void) | ||
32 | { | ||
33 | int i =0, j =0; | ||
34 | |||
35 | for (; i < 50000; i++) | ||
36 | j += prefix(); | ||
37 | } | ||
38 | |||
39 | #define CALL(sc) do { ret = sc; if (ret == -1) {perror(" (!!) " #sc " failed: "); /*exit(1)*/;}} while (0); | ||
40 | |||
41 | unsigned int job_no; | ||
42 | |||
43 | |||
44 | void next(void) | ||
45 | { | ||
46 | int ret; | ||
47 | unsigned int actual; | ||
48 | CALL(get_job_no(&actual)); | ||
49 | CALL(wait_for_job_release(++job_no)); | ||
50 | printf("Now executing job %u, waited for %u\n", actual, job_no); | ||
51 | } | ||
52 | |||
53 | void sync_jobs(void) | ||
54 | { | ||
55 | int ret; | ||
56 | unsigned int actual; | ||
57 | CALL(get_job_no(&actual)); | ||
58 | job_no = actual; | ||
59 | } | ||
60 | |||
61 | |||
62 | int main(int argc, char** argv) | ||
63 | { | ||
64 | int ret; | ||
65 | |||
66 | |||
67 | CALL(getpid()); | ||
68 | printf("my pid is %d\n", ret); | ||
69 | |||
70 | |||
71 | CALL(get_job_no(&job_no)); | ||
72 | printf("my job_no is %u", job_no); | ||
73 | |||
74 | next(); | ||
75 | next(); | ||
76 | next(); | ||
77 | |||
78 | /* now overrun a job for good */ | ||
79 | do_stuff(); | ||
80 | do_stuff(); | ||
81 | do_stuff(); | ||
82 | do_stuff(); | ||
83 | do_stuff(); | ||
84 | do_stuff(); | ||
85 | do_stuff(); | ||
86 | do_stuff(); | ||
87 | do_stuff(); | ||
88 | do_stuff(); | ||
89 | |||
90 | |||
91 | next(); | ||
92 | next(); | ||
93 | next(); | ||
94 | next(); | ||
95 | sync_jobs(); | ||
96 | next(); | ||
97 | next(); | ||
98 | next(); | ||
99 | |||
100 | |||
101 | return 0; | ||
102 | } | ||