diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-11-08 17:33:22 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-11-08 17:33:22 -0500 |
commit | 349b3d4954e480d08323d242ae13ad9242611b72 (patch) | |
tree | 6bcdcbc9f8e94144fe7df6534b0cda6cde88349b | |
parent | a087f2324e3da2263ee8f15560237d7677fba759 (diff) |
improve time handling
-rw-r--r-- | include/load.h | 2 | ||||
-rw-r--r-- | src/load.c | 6 | ||||
-rw-r--r-- | src/showst.c | 4 | ||||
-rw-r--r-- | src/st2pl.c | 25 |
4 files changed, 20 insertions, 17 deletions
diff --git a/include/load.h b/include/load.h index e460e7a..055df4c 100644 --- a/include/load.h +++ b/include/load.h | |||
@@ -49,7 +49,7 @@ void crop_events_all(double min, double max); | |||
49 | 49 | ||
50 | struct task* by_pid(int pid); | 50 | struct task* by_pid(int pid); |
51 | 51 | ||
52 | void split(struct heap* h, unsigned int count); | 52 | void split(struct heap* h, unsigned int count, int find_time0); |
53 | 53 | ||
54 | const char* tsk_name(struct task* t); | 54 | const char* tsk_name(struct task* t); |
55 | u32 per(struct task* t); | 55 | u32 per(struct task* t); |
@@ -130,14 +130,14 @@ u32 count_tasks(void) | |||
130 | 130 | ||
131 | { | 131 | { |
132 | struct task* t; | 132 | struct task* t; |
133 | u32 i = 0; | 133 | u32 i = 0; |
134 | for_each_task(t) | 134 | for_each_task(t) |
135 | i++; | 135 | i++; |
136 | return i; | 136 | return i; |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | void split(struct heap* h, unsigned int count) | 140 | void split(struct heap* h, unsigned int count, int find_time0) |
141 | { | 141 | { |
142 | struct evlink *lnk = malloc(count * sizeof(struct evlink)); | 142 | struct evlink *lnk = malloc(count * sizeof(struct evlink)); |
143 | struct heap_node *hn; | 143 | struct heap_node *hn; |
@@ -153,7 +153,7 @@ void split(struct heap* h, unsigned int count) | |||
153 | while ((hn = heap_take(earlier_event, h))) { | 153 | while ((hn = heap_take(earlier_event, h))) { |
154 | rec = heap_node_value(hn); | 154 | rec = heap_node_value(hn); |
155 | time = event_time(rec); | 155 | time = event_time(rec); |
156 | if (!time0 && time) | 156 | if (find_time0 && !time0 && time) |
157 | time0 = time; | 157 | time0 = time; |
158 | t = by_pid(rec->hdr.pid); | 158 | t = by_pid(rec->hdr.pid); |
159 | if (!t && rec->hdr.pid) { | 159 | if (!t && rec->hdr.pid) { |
diff --git a/src/showst.c b/src/showst.c index 6ef3e1f..5594ec5 100644 --- a/src/showst.c +++ b/src/showst.c | |||
@@ -18,10 +18,10 @@ int main(int argc, char** argv) | |||
18 | printf("Loaded %u events.\n", count); | 18 | printf("Loaded %u events.\n", count); |
19 | while ((hn = heap_take(earlier_event, h))) { | 19 | while ((hn = heap_take(earlier_event, h))) { |
20 | time = event_time(heap_node_value(hn)); | 20 | time = event_time(heap_node_value(hn)); |
21 | if (!start_time && time) | 21 | /* if (!start_time && time) |
22 | start_time = time; | 22 | start_time = time; |
23 | time -= start_time; | 23 | time -= start_time; |
24 | time /= 1000000; /* convert to milliseconds */ | 24 | */ time /= 1000000; /* convert to milliseconds */ |
25 | printf("[%10llu] ", time); | 25 | printf("[%10llu] ", time); |
26 | print_event(heap_node_value(hn)); | 26 | print_event(heap_node_value(hn)); |
27 | } | 27 | } |
diff --git a/src/st2pl.c b/src/st2pl.c index 537e7f7..881da66 100644 --- a/src/st2pl.c +++ b/src/st2pl.c | |||
@@ -24,7 +24,7 @@ static void write_prolog_kb(void) | |||
24 | for_each_task(t) { | 24 | for_each_task(t) { |
25 | for_each_event_t(t, e, ST_RELEASE) | 25 | for_each_event_t(t, e, ST_RELEASE) |
26 | printf("released(job(%u, %u), %f).\n", | 26 | printf("released(job(%u, %u), %f).\n", |
27 | e->rec->hdr.pid, | 27 | e->rec->hdr.pid, |
28 | e->rec->hdr.job, | 28 | e->rec->hdr.job, |
29 | ns2ms_adj(e->rec->data.release.release)); | 29 | ns2ms_adj(e->rec->data.release.release)); |
30 | } | 30 | } |
@@ -32,7 +32,7 @@ static void write_prolog_kb(void) | |||
32 | for_each_task(t) { | 32 | for_each_task(t) { |
33 | for_each_event_t(t, e, ST_RELEASE) | 33 | for_each_event_t(t, e, ST_RELEASE) |
34 | printf("deadline(job(%u, %u), %f).\n", | 34 | printf("deadline(job(%u, %u), %f).\n", |
35 | e->rec->hdr.pid, | 35 | e->rec->hdr.pid, |
36 | e->rec->hdr.job, | 36 | e->rec->hdr.job, |
37 | ns2ms_adj(e->rec->data.release.deadline)); | 37 | ns2ms_adj(e->rec->data.release.deadline)); |
38 | } | 38 | } |
@@ -126,7 +126,7 @@ static void write_asy(double from, double to, double scale) | |||
126 | for_each_event_t(t, e, ST_RELEASE) { | 126 | for_each_event_t(t, e, ST_RELEASE) { |
127 | t1 = ns2ms_adj(e->rec->data.release.release); | 127 | t1 = ns2ms_adj(e->rec->data.release.release); |
128 | t2 = ns2ms_adj(e->rec->data.release.deadline); | 128 | t2 = ns2ms_adj(e->rec->data.release.deadline); |
129 | if (in_range(from, t1, to)) | 129 | if (in_range(from, t1, to)) |
130 | printf("release(%u, %f);\n", idx(t), t1); | 130 | printf("release(%u, %f);\n", idx(t), t1); |
131 | if (in_range(from, t2, to)) | 131 | if (in_range(from, t2, to)) |
132 | printf("deadline(%u, %f);\n", idx(t), t2); | 132 | printf("deadline(%u, %f);\n", idx(t), t2); |
@@ -164,7 +164,7 @@ static void write_asy(double from, double to, double scale) | |||
164 | 164 | ||
165 | static void usage(const char *str) | 165 | static void usage(const char *str) |
166 | { | 166 | { |
167 | fprintf(stderr, | 167 | fprintf(stderr, |
168 | "\n USAGE\n" | 168 | "\n USAGE\n" |
169 | "\n" | 169 | "\n" |
170 | " st2pl [opts] <file.st>+\n" | 170 | " st2pl [opts] <file.st>+\n" |
@@ -182,7 +182,7 @@ static void usage(const char *str) | |||
182 | typedef enum { | 182 | typedef enum { |
183 | UNKNOWN, | 183 | UNKNOWN, |
184 | PROLOG, | 184 | PROLOG, |
185 | ASYMPTOTE, | 185 | ASYMPTOTE, |
186 | } lang_t; | 186 | } lang_t; |
187 | 187 | ||
188 | #define streq(a, b) (0 == strcmp(a, b)) | 188 | #define streq(a, b) (0 == strcmp(a, b)) |
@@ -235,15 +235,18 @@ int main(int argc, char** argv) | |||
235 | break; | 235 | break; |
236 | case 'm': | 236 | case 'm': |
237 | g_min_task = atoi(optarg); | 237 | g_min_task = atoi(optarg); |
238 | if (g_min_task > g_max_task) | 238 | if (g_min_task > g_max_task) { |
239 | g_min_task = g_max_task; | 239 | usage("-m cannot exceed -M."); |
240 | } | ||
240 | break; | 241 | break; |
241 | case 'M': | 242 | case 'M': |
242 | g_max_task = atoi(optarg); | 243 | g_max_task = atoi(optarg); |
243 | if (g_min_task > g_max_task) | 244 | if (g_min_task > g_max_task) { |
244 | g_max_task = g_min_task; | 245 | usage("-m cannot exceed -M."); |
245 | if (g_max_task > MAX_TASKS) | 246 | } |
247 | if (g_max_task > MAX_TASKS) { | ||
246 | g_max_task = MAX_TASKS; | 248 | g_max_task = MAX_TASKS; |
249 | } | ||
247 | break; | 250 | break; |
248 | case 'h': | 251 | case 'h': |
249 | usage("Help requested."); | 252 | usage("Help requested."); |
@@ -263,7 +266,7 @@ int main(int argc, char** argv) | |||
263 | if (!h) | 266 | if (!h) |
264 | usage("Loading traces failed."); | 267 | usage("Loading traces failed."); |
265 | fprintf(stderr, "Loaded %u events.\n", count); | 268 | fprintf(stderr, "Loaded %u events.\n", count); |
266 | split(h, count); | 269 | split(h, count, 0); |
267 | switch (mode) { | 270 | switch (mode) { |
268 | case PROLOG: | 271 | case PROLOG: |
269 | crop_events_all(from, to); | 272 | crop_events_all(from, to); |