From aa387e17f6d5dcd2847ba142c6d4a8d7e5b5054d Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 29 Oct 2008 23:10:19 -0400 Subject: add event_time(), remove cruft --- src/sched_trace.c | 63 ++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/sched_trace.c b/src/sched_trace.c index 330ed27..434b0d7 100644 --- a/src/sched_trace.c +++ b/src/sched_trace.c @@ -1,6 +1,7 @@ #include #include + #include #include #include @@ -10,42 +11,6 @@ #include "litmus.h" #include "sched_trace.h" -static int map_file(const char* filename, void **addr, size_t *size) -{ - struct stat info; - int error = 0; - int fd; - - error = stat(filename, &info); - if (!error) { - *size = info.st_size; - if (info.st_size > 0) { - fd = open(filename, O_RDONLY); - if (fd >= 0) { - *addr = mmap(NULL, *size, - PROT_READ | PROT_WRITE, - MAP_PRIVATE, fd, 0); - if (*addr == MAP_FAILED) - error = -1; - close(fd); - } else - error = fd; - } else - *addr = NULL; - } - return error; -} - -static int map_trace(const char *name, void **start, void **end, size_t *size) -{ - int ret; - - ret = map_file(name, start, size); - if (!ret) - *end = *start + *size; - return ret; -} - static const char* event_names[] = { "INVALID", "NAME", @@ -70,6 +35,30 @@ const char* event2name(unsigned int id) return event_names[id]; } + +u64 event_time(struct st_event_record* rec) +{ + u64 when; + switch (rec->hdr.type) { + /* the time stamp is encoded in the first payload u64 */ + case ST_RELEASE: + case ST_ASSIGNED: + case ST_SWITCH_TO: + case ST_SWITCH_AWAY: + case ST_COMPLETION: + case ST_BLOCK: + case ST_RESUME: + when = rec->data.raw[0]; + break; + default: + /* stuff that doesn't have a time stamp should occur "early" */ + when = 0; + break; + }; + return when; +} + + void print_header(struct st_trace_header* hdr) { printf("%-14s %5u/%-5u on CPU%3u ", @@ -123,10 +112,8 @@ void print_event(struct st_event_record *rec) print_header(&rec->hdr); print_detail[id](rec); printf("\n"); - return event_names[id]; } - void print_all(struct st_event_record *rec, unsigned int count) { unsigned int i; -- cgit v1.2.2