aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2013-01-11 04:17:10 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-01-11 04:24:18 -0500
commit642049ba7d30b24fb9927a22d44d6b84139668dc (patch)
treeeaa73b8f77c949b1a56ab0271bda5be7b3746725
parentd427bf8561f488bfec36b14b02af5b8ca0b2782f (diff)
Make release_ts a bit more userfriendly
The -f option required manually *also* setting the -w option. This is no longer required. While at it, simplify the code by using the /proc interface.
-rw-r--r--bin/release_ts.c28
-rw-r--r--include/litmus.h1
-rw-r--r--src/kernel_iface.c15
3 files changed, 15 insertions, 29 deletions
diff --git a/bin/release_ts.c b/bin/release_ts.c
index 7752097..c2f6d4c 100644
--- a/bin/release_ts.c
+++ b/bin/release_ts.c
@@ -31,35 +31,14 @@ void usage(char *error) {
31void wait_until_ready(int expected) 31void wait_until_ready(int expected)
32{ 32{
33 int ready = 0, all = 0; 33 int ready = 0, all = 0;
34 char buf[100];
35 int loops = 0; 34 int loops = 0;
36 ssize_t len;
37
38 35
39 do { 36 do {
40 if (loops++ > 0) 37 if (loops++ > 0)
41 sleep(1); 38 sleep(1);
42 len = read_file(LITMUS_STATS_FILE, buf, sizeof(buf) - 1); 39 if (!read_litmus_stats(&ready, &all))
43 if (len < 0) { 40 perror("read_litmus_stats");
44 fprintf(stderr, 41 } while (expected > ready || (!expected && ready < all));
45 "(EE) Error while reading '%s': %m.\n"
46 "(EE) Ignoring -w option.\n",
47 LITMUS_STATS_FILE);
48 break;
49 } else {
50 len = sscanf(buf,
51 "real-time tasks = %d\n"
52 "ready for release = %d\n",
53 &all, &ready);
54 if (len != 2) {
55 fprintf(stderr,
56 "(EE) Could not parse '%s'.\n"
57 "(EE) Ignoring -w option.\n",
58 LITMUS_STATS_FILE);
59 break;
60 }
61 }
62 } while (expected > ready || ready < all);
63} 42}
64 43
65int main(int argc, char** argv) 44int main(int argc, char** argv)
@@ -79,6 +58,7 @@ int main(int argc, char** argv)
79 wait = 1; 58 wait = 1;
80 break; 59 break;
81 case 'f': 60 case 'f':
61 wait = 1;
82 expected = atoi(optarg); 62 expected = atoi(optarg);
83 break; 63 break;
84 case ':': 64 case ':':
diff --git a/include/litmus.h b/include/litmus.h
index 677f9a9..3777088 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -121,6 +121,7 @@ int requested_to_preempt(void);
121int wait_for_ts_release(void); 121int wait_for_ts_release(void);
122int release_ts(lt_t *delay); 122int release_ts(lt_t *delay);
123int get_nr_ts_release_waiters(void); 123int get_nr_ts_release_waiters(void);
124int read_litmus_stats(int *ready, int *total);
124 125
125#define __NS_PER_MS 1000000 126#define __NS_PER_MS 1000000
126 127
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index 4cc1af5..e446102 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -56,9 +56,8 @@ ssize_t read_file(const char* fname, void* buf, size_t maxlen)
56 return got; 56 return got;
57} 57}
58 58
59int get_nr_ts_release_waiters(void) 59int read_litmus_stats(int *ready, int *all)
60{ 60{
61 int ready = 0, all = 0;
62 char buf[100]; 61 char buf[100];
63 ssize_t len; 62 ssize_t len;
64 63
@@ -67,11 +66,17 @@ int get_nr_ts_release_waiters(void)
67 len = sscanf(buf, 66 len = sscanf(buf,
68 "real-time tasks = %d\n" 67 "real-time tasks = %d\n"
69 "ready for release = %d\n", 68 "ready for release = %d\n",
70 &all, &ready); 69 all, ready);
71 if (len == 2) 70 return len == 2;
71}
72
73int get_nr_ts_release_waiters(void)
74{
75 int ready, all;
76 if (read_litmus_stats(&ready, &all))
72 return ready; 77 return ready;
73 else 78 else
74 return len; 79 return -1;
75} 80}
76 81
77/* thread-local pointer to control page */ 82/* thread-local pointer to control page */