diff options
| -rw-r--r-- | src/sched_trace.c | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/src/sched_trace.c b/src/sched_trace.c index 9f532f3..330ed27 100644 --- a/src/sched_trace.c +++ b/src/sched_trace.c | |||
| @@ -62,6 +62,7 @@ static const char* event_names[] = { | |||
| 62 | 62 | ||
| 63 | #define ST_INVALID (ST_RESUME + 1) | 63 | #define ST_INVALID (ST_RESUME + 1) |
| 64 | 64 | ||
| 65 | |||
| 65 | const char* event2name(unsigned int id) | 66 | const char* event2name(unsigned int id) |
| 66 | { | 67 | { |
| 67 | if (id >= ST_INVALID) | 68 | if (id >= ST_INVALID) |
| @@ -71,16 +72,64 @@ const char* event2name(unsigned int id) | |||
| 71 | 72 | ||
| 72 | void print_header(struct st_trace_header* hdr) | 73 | void print_header(struct st_trace_header* hdr) |
| 73 | { | 74 | { |
| 74 | printf("%-14s on CPU %u for %5u/%5u", | 75 | printf("%-14s %5u/%-5u on CPU%3u ", |
| 75 | event2name(hdr->type), | 76 | event2name(hdr->type), |
| 76 | hdr->cpu, hdr->pid, hdr->job); | 77 | hdr->pid, hdr->job, |
| 78 | hdr->cpu); | ||
| 79 | } | ||
| 80 | |||
| 81 | typedef void (*print_t)(struct st_event_record* rec); | ||
| 82 | |||
| 83 | static void print_nothing(struct st_event_record* _) | ||
| 84 | { | ||
| 85 | } | ||
| 86 | |||
| 87 | static void print_name(struct st_event_record* rec) | ||
| 88 | { | ||
| 89 | /* terminate in all cases */ | ||
| 90 | rec->data.name.cmd[ST_NAME_LEN - 1] = 0; | ||
| 91 | printf("%s", rec->data.name.cmd); | ||
| 92 | } | ||
| 93 | |||
| 94 | static void print_param(struct st_event_record* rec) | ||
| 95 | { | ||
| 96 | printf("T=(cost:%6.2fms, period:%6.2fms, phase:%6.2fms), part=%d", | ||
| 97 | rec->data.param.wcet / 1000000.0, | ||
| 98 | rec->data.param.period / 1000000.0, | ||
| 99 | rec->data.param.phase / 1000000.0,\ | ||
| 100 | rec->data.param.partition); | ||
| 77 | } | 101 | } |
| 78 | 102 | ||
| 103 | static print_t print_detail[] = { | ||
| 104 | print_nothing, | ||
| 105 | print_name, | ||
| 106 | print_param, | ||
| 107 | print_nothing, | ||
| 108 | print_nothing, | ||
| 109 | print_nothing, | ||
| 110 | print_nothing, | ||
| 111 | print_nothing, | ||
| 112 | print_nothing, | ||
| 113 | print_nothing, | ||
| 114 | print_nothing | ||
| 115 | }; | ||
| 116 | |||
| 117 | void print_event(struct st_event_record *rec) | ||
| 118 | { | ||
| 119 | unsigned int id = rec->hdr.type; | ||
| 120 | |||
| 121 | if (id >= ST_INVALID) | ||
| 122 | id = ST_INVALID; | ||
| 123 | print_header(&rec->hdr); | ||
| 124 | print_detail[id](rec); | ||
| 125 | printf("\n"); | ||
| 126 | return event_names[id]; | ||
| 127 | } | ||
| 128 | |||
| 129 | |||
| 79 | void print_all(struct st_event_record *rec, unsigned int count) | 130 | void print_all(struct st_event_record *rec, unsigned int count) |
| 80 | { | 131 | { |
| 81 | unsigned int i; | 132 | unsigned int i; |
| 82 | for (i = 0; i < count; i++) { | 133 | for (i = 0; i < count; i++) |
| 83 | print_header(&rec[i].hdr); | 134 | print_event(&rec[i]); |
| 84 | printf("\n"); | ||
| 85 | } | ||
| 86 | } | 135 | } |
