aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2009-04-14 23:13:30 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2009-04-14 23:25:06 -0400
commit715800e7610887ce87b5b6af61f9bddfdc29d97d (patch)
treec0c565eb2b0cf4ac0892848b2590154b0417c0cc
parentff0f490ff95fbe0ee4c9e5408e4eca84ab9ee770 (diff)
remove sched_trace stuff from liblitmus
-rw-r--r--.gitignore1
-rw-r--r--SConstruct9
-rw-r--r--bin/showst.c66
-rw-r--r--include/sched_trace.h20
-rw-r--r--src/sched_trace.c135
5 files changed, 1 insertions, 230 deletions
diff --git a/.gitignore b/.gitignore
index a3055cf..006aaa5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@ rtspin
14cycles 14cycles
15.sconsign.dblite 15.sconsign.dblite
16.sconf_temp/* 16.sconf_temp/*
17measure_syscall \ No newline at end of file
diff --git a/SConstruct b/SConstruct
index a3a7ea4..f0f754d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -82,13 +82,6 @@ if not env.GetOption('clean'):
82 Exit(1) 82 Exit(1)
83 env = conf.Finish() 83 env = conf.Finish()
84 84
85# link with libst
86st = env.Clone(
87 LIBS = 'st',
88 LIBPATH = '.'
89)
90
91
92# link with liblitmus 85# link with liblitmus
93rt = env.Clone( 86rt = env.Clone(
94 LIBS = Split('litmus rt'), 87 LIBS = Split('litmus rt'),
@@ -111,7 +104,6 @@ mtrt.Append(LINKFLAGS = '-pthread')
111env.Library('litmus', 104env.Library('litmus',
112 ['src/kernel_iface.c', 'src/litmus.c', 105 ['src/kernel_iface.c', 'src/litmus.c',
113 'src/syscalls.c', 'src/task.c']) 106 'src/syscalls.c', 'src/task.c'])
114env.Library('st', ['src/sched_trace.c'])
115 107
116# ##################################################################### 108# #####################################################################
117# Targets: simple tools that do not depend on liblitmus 109# Targets: simple tools that do not depend on liblitmus
@@ -128,4 +120,3 @@ rt.Program('rt_launch', ['bin/rt_launch.c', 'bin/common.c'])
128rt.Program('rtspin', ['bin/rtspin.c', 'bin/common.c']) 120rt.Program('rtspin', ['bin/rtspin.c', 'bin/common.c'])
129rt.Program('release_ts', 'bin/release_ts.c') 121rt.Program('release_ts', 'bin/release_ts.c')
130rtm.Program('measure_syscall', 'bin/null_call.c') 122rtm.Program('measure_syscall', 'bin/null_call.c')
131st.Program('showst', 'bin/showst.c')
diff --git a/bin/showst.c b/bin/showst.c
deleted file mode 100644
index 68d8b50..0000000
--- a/bin/showst.c
+++ /dev/null
@@ -1,66 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <sys/mman.h>
6#include <fcntl.h>
7#include <unistd.h>
8
9#include "sched_trace.h"
10
11static int map_file(const char* filename, void **addr, size_t *size)
12{
13 struct stat info;
14 int error = 0;
15 int fd;
16
17 error = stat(filename, &info);
18 if (!error) {
19 *size = info.st_size;
20 if (info.st_size > 0) {
21 fd = open(filename, O_RDONLY);
22 if (fd >= 0) {
23 *addr = mmap(NULL, *size,
24 PROT_READ | PROT_WRITE,
25 MAP_PRIVATE, fd, 0);
26 if (*addr == MAP_FAILED)
27 error = -1;
28 close(fd);
29 } else
30 error = fd;
31 } else
32 *addr = NULL;
33 }
34 return error;
35}
36
37static int map_trace(const char *name, void **start, void **end, size_t *size)
38{
39 int ret;
40
41 ret = map_file(name, start, size);
42 if (!ret)
43 *end = *start + *size;
44 return ret;
45}
46
47
48static void show(char* file)
49{
50 size_t s;
51 struct st_event_record *rec, *end;
52 if (map_trace(file, &rec, &end, &s) == 0) {
53 print_all(rec,
54 ((unsigned int)((char*) end - (char*) rec))
55 / sizeof(struct st_event_record));
56 } else
57 perror("mmap");
58}
59
60int main(int argc, char** argv)
61{
62 int i;
63 for (i = 1; i < argc; i++)
64 show(argv[i]);
65 return 0;
66}
diff --git a/include/sched_trace.h b/include/sched_trace.h
deleted file mode 100644
index 1d2b3ac..0000000
--- a/include/sched_trace.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef __SCHED_TRACE_H_
2#define __SCHED_TRACE_H_
3
4#include <linux/types.h>
5
6typedef __u8 u8;
7typedef __u32 u32;
8typedef __u16 u16;
9typedef __u64 u64;
10
11#include <litmus/sched_trace.h>
12
13const char* event2name(unsigned int id);
14u64 event_time(struct st_event_record* rec);
15
16void print_event(struct st_event_record *rec);
17void print_all(struct st_event_record *rec, unsigned int count);
18
19
20#endif
diff --git a/src/sched_trace.c b/src/sched_trace.c
deleted file mode 100644
index 464d75b..0000000
--- a/src/sched_trace.c
+++ /dev/null
@@ -1,135 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3
4
5#include <sys/types.h>
6#include <sys/stat.h>
7#include <sys/mman.h>
8#include <fcntl.h>
9#include <unistd.h>
10
11#include "litmus.h"
12#include "sched_trace.h"
13
14static const char* event_names[] = {
15 "INVALID",
16 "NAME",
17 "PARAM",
18 "RELEASE",
19 "ASSIGNED",
20 "SWITCH_TO",
21 "SWITCH_FROM",
22 "COMPLETION",
23 "BLOCK",
24 "RESUME",
25 "SYS_RELEASE",
26 "INVALID"
27};
28
29#define ST_INVALID (ST_SYS_RELEASE + 1)
30
31
32const char* event2name(unsigned int id)
33{
34 if (id >= ST_INVALID)
35 id = ST_INVALID;
36 return event_names[id];
37}
38
39
40u64 event_time(struct st_event_record* rec)
41{
42 u64 when;
43 switch (rec->hdr.type) {
44 /* the time stamp is encoded in the first payload u64 */
45 case ST_RELEASE:
46 case ST_ASSIGNED:
47 case ST_SWITCH_TO:
48 case ST_SWITCH_AWAY:
49 case ST_COMPLETION:
50 case ST_BLOCK:
51 case ST_RESUME:
52 case ST_SYS_RELEASE:
53 when = rec->data.raw[0];
54 break;
55 default:
56 /* stuff that doesn't have a time stamp should occur "early" */
57 when = 0;
58 break;
59 };
60 return when;
61}
62
63
64void print_header(struct st_trace_header* hdr)
65{
66 printf("%-14s %5u/%-5u on CPU%3u ",
67 event2name(hdr->type),
68 hdr->pid, hdr->job,
69 hdr->cpu);
70}
71
72typedef void (*print_t)(struct st_event_record* rec);
73
74static void print_nothing(struct st_event_record* _)
75{
76}
77
78static void print_raw(struct st_event_record* rec)
79{
80 printf(" type=%u", rec->hdr.type);
81}
82
83static void print_name(struct st_event_record* rec)
84{
85 /* terminate in all cases */
86 rec->data.name.cmd[ST_NAME_LEN - 1] = 0;
87 printf("%s", rec->data.name.cmd);
88}
89
90static void print_param(struct st_event_record* rec)
91{
92 printf("T=(cost:%6.2fms, period:%6.2fms, phase:%6.2fms), part=%d",
93 rec->data.param.wcet / 1000000.0,
94 rec->data.param.period / 1000000.0,
95 rec->data.param.phase / 1000000.0,\
96 rec->data.param.partition);
97}
98
99static void print_time_data2(struct st_event_record* rec)
100{
101 printf("%6.2fms", rec->data.raw[1] / 1000000.0);
102}
103
104static print_t print_detail[] = {
105 print_raw, /* invalid */
106 print_name, /* NAME */
107 print_param, /* PARAM */
108 print_time_data2, /* RELEASE */
109 print_nothing, /* ASSIGNED */
110 print_nothing, /* SWITCH_TO */
111 print_nothing, /* SWITCH_FROM */
112 print_nothing, /* COMPLETION */
113 print_nothing, /* BLOCK */
114 print_nothing, /* RESUME */
115 print_time_data2, /* SYS_RELEASE */
116 print_raw, /* invalid */
117};
118
119void print_event(struct st_event_record *rec)
120{
121 unsigned int id = rec->hdr.type;
122
123 if (id >= ST_INVALID)
124 id = ST_INVALID;
125 print_header(&rec->hdr);
126 print_detail[id](rec);
127 printf("\n");
128}
129
130void print_all(struct st_event_record *rec, unsigned int count)
131{
132 unsigned int i;
133 for (i = 0; i < count; i++)
134 print_event(&rec[i]);
135}