diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-01-23 11:26:36 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-01-23 11:26:36 -0500 |
commit | 7e062f5db3e3888cda2d0915e14d33b9f69c4c68 (patch) | |
tree | 9ef810155fc51b564e764e448478f37b169ea507 /bin/hrt.c | |
parent | d56b86e42b72abb68ba74bf540ddc259f6b20f84 (diff) |
Reorganized file layout.
Diffstat (limited to 'bin/hrt.c')
-rw-r--r-- | bin/hrt.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/bin/hrt.c b/bin/hrt.c new file mode 100644 index 0000000..224293c --- /dev/null +++ b/bin/hrt.c | |||
@@ -0,0 +1,78 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | |||
5 | #include "edf-hsb.h" | ||
6 | |||
7 | |||
8 | void usage(char *name) | ||
9 | { | ||
10 | fprintf(stderr, | ||
11 | "EDF-HSB server setup utility\n" | ||
12 | "Usage: %s hrt show <#cpu>\n" | ||
13 | " %s hrt set <#cpu> <wcet> <period>\n" | ||
14 | " %s be create <wcet> <period>\n", | ||
15 | name, name, name); | ||
16 | exit(1); | ||
17 | } | ||
18 | |||
19 | |||
20 | int hrt(int argc, char** argv) | ||
21 | { | ||
22 | int wcet, period, cpu; | ||
23 | |||
24 | if (argc == 2 && !strcmp(argv[0], "show")) { | ||
25 | cpu = atoi(argv[1]); | ||
26 | if (!get_hrt(cpu, &wcet, &period)) | ||
27 | printf("HRT/%d = (%d, %d)\n", cpu, wcet, period); | ||
28 | else | ||
29 | perror("cannot read HRT settings"); | ||
30 | } else if (argc == 4 && !strcmp(argv[0], "set")) { | ||
31 | cpu = atoi(argv[1]); | ||
32 | wcet = atoi(argv[2]); | ||
33 | period = atoi(argv[3]); | ||
34 | printf("Setting HRT/%d to (%d, %d)", cpu, wcet, period); | ||
35 | if (!set_hrt(cpu, wcet, period)) | ||
36 | printf(" OK.\n"); | ||
37 | else { | ||
38 | printf("\n"); | ||
39 | perror("cannot write HRT settings"); | ||
40 | } | ||
41 | } else | ||
42 | return 1; | ||
43 | |||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | int be(int argc, char** argv) | ||
48 | { | ||
49 | int wcet, period; | ||
50 | if (argc == 3 && !strcmp(argv[0], "create")) { | ||
51 | wcet = atoi(argv[1]); | ||
52 | period = atoi(argv[2]); | ||
53 | printf("Creating BE with (%d, %d)", wcet, period); | ||
54 | if (!create_be(wcet, period)) | ||
55 | printf(" OK.\n"); | ||
56 | else { | ||
57 | printf("\n"); | ||
58 | perror("cannot create BE server"); | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | else | ||
63 | return 1; | ||
64 | } | ||
65 | |||
66 | int main(int argc, char** argv) | ||
67 | { | ||
68 | int ret = 1; | ||
69 | if (argc > 1) { | ||
70 | if (!strcmp(argv[1], "hrt")) | ||
71 | ret = hrt(argc - 2, argv + 2); | ||
72 | else if (!strcmp(argv[1], "be")) | ||
73 | ret = be(argc - 2, argv + 2); | ||
74 | } | ||
75 | if (ret) | ||
76 | usage(argv[0]); | ||
77 | return ret; | ||
78 | } | ||