aboutsummaryrefslogtreecommitdiffstats
path: root/bin/mode_request.c
diff options
context:
space:
mode:
authorNamhoon Kim <namhoonk@cs.unc.edu>2017-05-01 16:02:05 -0400
committerNamhoon Kim <namhoonk@cs.unc.edu>2017-05-01 16:02:05 -0400
commit11765fcf37057053065abd3715cf9cb46f2fa4db (patch)
tree8403d716bbcbd96493c481a82e7e02b5da9231e8 /bin/mode_request.c
parentbfee87a910560e022b04c81a026b1f88522cd62f (diff)
RTSS17 submitwip-modechange
Diffstat (limited to 'bin/mode_request.c')
-rw-r--r--bin/mode_request.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/bin/mode_request.c b/bin/mode_request.c
index a0b3226..010add1 100644
--- a/bin/mode_request.c
+++ b/bin/mode_request.c
@@ -1,13 +1,49 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <errno.h>
4#include <sys/syscall.h>
5#include <unistd.h>
6#include <signal.h>
7
1#include "litmus.h" 8#include "litmus.h"
2 9
3#define __NR_request_mode 408 10#define __NR_request_mode 408
4 11
5int main(int argc, char* argv){ 12static int keep_running;
6 int ret, req_mode; 13
7 if (argc < 2){ 14void sig_handler(int signum) {
8 return -EINVAL; 15 int ret;
16
17 usleep(100000);
18 ret = syscall(__NR_request_mode, 0);
19 usleep(1000000);
20 keep_running = 0;
21
22}
23
24int main(int argc, char* argv[]) {
25 int ret, req_mode = 0;
26 int interval_ms;
27 int max_mode = 9;
28
29 signal(SIGINT, sig_handler);
30
31 if (argc == 2) {
32 max_mode = atoi(argv[1]);
33 printf("%d\n", max_mode);
34 }
35
36 keep_running = 1;
37 usleep(500000); // ms
38 while (keep_running) {
39 req_mode = (req_mode%max_mode)+1;
40
41 if (keep_running)
42 ret = syscall(__NR_request_mode, req_mode);
43 interval_ms = rand() % 1000 - 500; // ms
44 usleep(1000*(1000 + interval_ms));
9 } 45 }
10 req_mode = atoi(argv[1]); 46
11 ret = syscall(__NR_request_mode, req_mode); 47
12 return ret; 48 return ret;
13} 49}