diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-02-19 15:51:14 -0500 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-02-19 15:51:14 -0500 |
| commit | 70427f6589c75d2cff7983f93d58a9728d6eebf2 (patch) | |
| tree | 792b1f8cec453e2aa5400946c041de1115448040 /bin | |
| parent | 423ad81dd18d5e696537bce1bdf5772ad55490ca (diff) | |
add release_ts utility
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/release_ts.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/bin/release_ts.c b/bin/release_ts.c new file mode 100644 index 0000000..4d4c9e8 --- /dev/null +++ b/bin/release_ts.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | #include <stdlib.h> | ||
| 2 | #include <stdio.h> | ||
| 3 | #include <unistd.h> | ||
| 4 | |||
| 5 | #include "litmus.h" | ||
| 6 | |||
| 7 | #define OPTSTR "d:" | ||
| 8 | #define NS_PER_MS 1000000 | ||
| 9 | |||
| 10 | void usage(char *error) { | ||
| 11 | fprintf(stderr, | ||
| 12 | "%s\n" | ||
| 13 | "Usage: release_ts [-d <delay in ms>]\n", | ||
| 14 | error); | ||
| 15 | exit(1); | ||
| 16 | } | ||
| 17 | |||
| 18 | |||
| 19 | int main(int argc, char** argv) | ||
| 20 | { | ||
| 21 | int released; | ||
| 22 | lt_t delay = ms2lt(1000); | ||
| 23 | int opt; | ||
| 24 | |||
| 25 | while ((opt = getopt(argc, argv, OPTSTR)) != -1) { | ||
| 26 | switch (opt) { | ||
| 27 | case 'd': | ||
| 28 | delay = ms2lt(atoi(optarg)); | ||
| 29 | break; | ||
| 30 | case ':': | ||
| 31 | usage("Argument missing."); | ||
| 32 | break; | ||
| 33 | case '?': | ||
| 34 | default: | ||
| 35 | usage("Bad argument."); | ||
| 36 | break; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | released = release_ts(&delay); | ||
| 41 | if (released < 0) { | ||
| 42 | perror("release task system"); | ||
| 43 | exit(1); | ||
| 44 | } | ||
| 45 | |||
| 46 | printf("Released %d real-time tasks.\n", released); | ||
| 47 | |||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | |||
