aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2012-09-16 20:46:19 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2012-09-16 20:46:19 -0400
commitbdb33621ac67b2cd9fadf3f3b006419ebb16a713 (patch)
tree8918b5dbc6db8a73c275e445153c7ea42857210b
parentfd92ecb5a642eeae6c54d3cca1508fc4c4cb6a87 (diff)
Created run_exps.py script.
Currently poorly documented.
-rw-r--r--.gitignore4
-rw-r--r--__init__.py0
-rw-r--r--config/__init__.py0
-rw-r--r--config/config.example.py46
-rw-r--r--config/config.py46
-rw-r--r--experiment/__init__.py0
-rw-r--r--experiment/executable/__init__.py0
-rw-r--r--experiment/executable/executable.py71
-rw-r--r--experiment/executable/ftcat.py33
-rw-r--r--experiment/experiment.py153
-rw-r--r--experiment/litmus_util.py63
-rw-r--r--experiment/proc_entry.py12
-rw-r--r--experiment/tracer.py118
-rwxr-xr-x[-rw-r--r--]run_exps.py192
14 files changed, 738 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7c62cf4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
1*~
2\#*#
3*.pyc
4.ropeproject* \ No newline at end of file
diff --git a/__init__.py b/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/__init__.py
diff --git a/config/__init__.py b/config/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/config/__init__.py
diff --git a/config/config.example.py b/config/config.example.py
new file mode 100644
index 0000000..5176460
--- /dev/null
+++ b/config/config.example.py
@@ -0,0 +1,46 @@
1from __future__ import print_function
2import os
3import sys
4
5REPOS = {'liblitmus' : '/home/hermanjl/git/liblitmus',
6 'sched_trace' : '/home/hermanjl/git/sched_trace',
7 'analysis' : '/home/hermanjl/git/overhead-analysis-cjk',
8 'ft_tools' : '/home/hermanjl/git/ft_tools/ftcat',
9 'trace-cmd' : '/home/hermanjl/git/trace-cmd'}
10
11BINS = {'bespin' : '{}/bespin'.format(REPOS['liblitmus']),
12 'colorspin' : '{}/colorspin'.format(REPOS['liblitmus']),
13 'rtspin' : '{}/rtspin'.format(REPOS['liblitmus']),
14 'release' : '{}/release_ts'.format(REPOS['liblitmus']),
15 'ftcat' : '{}/ftcat'.format(REPOS['ft_tools']),
16 'st_trace' : '{}/st_trace'.format(REPOS['ft_tools']),
17 'split' : '{}/split'.format(REPOS['analysis']),
18 'sort' : '{}/sort-all'.format(REPOS['analysis']),
19 'analyze' : '{}/analyze'.format(REPOS['analysis']),
20 'trace-cmd' : '{}/trace-cmd'.format(REPOS['trace-cmd'])}
21
22DEFAULTS = {'params_file' : 'params.py',
23 'sched_file' : 'sched.py',
24 'exps_file' : 'exps.py',
25 'duration' : '10',
26 'spin' : 'rtspin'}
27
28FILES = {'ft_data' : 'ft.bin',
29 'linux_data' : 'trace.dat',
30 'sched_data' : 'st-{}.bin',
31 'log_data' : 'trace.slog'}
32
33PARAMS = {'sched' : 'scheduler',
34 'dur' : 'duration'}
35
36valid = True
37for repo, loc in REPOS.items():
38 if not os.path.isdir(loc):
39 valid = False
40 print("Cannot access repo '%s' at '%s'" % (repo, loc), file=sys.stderr)
41for prog, loc in BINS.items():
42 if not os.path.isfile(loc):
43 valid = False
44 print("Cannot access program '%s' at '%s'" % (prog, loc), file=sys.stderr)
45if not valid:
46 print("Errors in config file", file=sys.stderr)
diff --git a/config/config.py b/config/config.py
new file mode 100644
index 0000000..5176460
--- /dev/null
+++ b/config/config.py
@@ -0,0 +1,46 @@
1from __future__ import print_function
2import os
3import sys
4
5REPOS = {'liblitmus' : '/home/hermanjl/git/liblitmus',
6 'sched_trace' : '/home/hermanjl/git/sched_trace',
7 'analysis' : '/home/hermanjl/git/overhead-analysis-cjk',
8 'ft_tools' : '/home/hermanjl/git/ft_tools/ftcat',
9 'trace-cmd' : '/home/hermanjl/git/trace-cmd'}
10
11BINS = {'bespin' : '{}/bespin'.format(REPOS['liblitmus']),
12 'colorspin' : '{}/colorspin'.format(REPOS['liblitmus']),
13 'rtspin' : '{}/rtspin'.format(REPOS['liblitmus']),
14 'release' : '{}/release_ts'.format(REPOS['liblitmus']),
15 'ftcat' : '{}/ftcat'.format(REPOS['ft_tools']),
16 'st_trace' : '{}/st_trace'.format(REPOS['ft_tools']),
17 'split' : '{}/split'.format(REPOS['analysis']),
18 'sort' : '{}/sort-all'.format(REPOS['analysis']),
19 'analyze' : '{}/analyze'.format(REPOS['analysis']),
20 'trace-cmd' : '{}/trace-cmd'.format(REPOS['trace-cmd'])}
21
22DEFAULTS = {'params_file' : 'params.py',
23 'sched_file' : 'sched.py',
24 'exps_file' : 'exps.py',
25 'duration' : '10',
26 'spin' : 'rtspin'}
27
28FILES = {'ft_data' : 'ft.bin',
29 'linux_data' : 'trace.dat',
30 'sched_data' : 'st-{}.bin',
31 'log_data' : 'trace.slog'}
32
33PARAMS = {'sched' : 'scheduler',
34 'dur' : 'duration'}
35
36valid = True
37for repo, loc in REPOS.items():
38 if not os.path.isdir(loc):
39 valid = False
40 print("Cannot access repo '%s' at '%s'" % (repo, loc), file=sys.stderr)
41for prog, loc in BINS.items():
42 if not os.path.isfile(loc):
43 valid = False
44 print("Cannot access program '%s' at '%s'" % (prog, loc), file=sys.stderr)
45if not valid:
46 print("Errors in config file", file=sys.stderr)
diff --git a/experiment/__init__.py b/experiment/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/experiment/__init__.py
diff --git a/experiment/executable/__init__.py b/experiment/executable/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/experiment/executable/__init__.py
diff --git a/experiment/executable/executable.py b/experiment/executable/executable.py
new file mode 100644
index 0000000..6697a8d
--- /dev/null
+++ b/experiment/executable/executable.py
@@ -0,0 +1,71 @@
1import sys
2import subprocess
3import signal
4from ..litmus_util import is_executable
5
6class Executable(object):
7 """Parent object that represents an executable for use in task-sets."""
8
9 def __init__(self, exec_file, extra_args=None, stdout_file = None, stderr_file = None):
10 self.exec_file = exec_file
11 self.cwd = None
12 self.stdout_file = stdout_file
13 self.stderr_file = stderr_file
14 self.sp = None
15
16 if extra_args is None:
17 self.extra_args = None
18 else:
19 self.extra_args = list(extra_args) # make a duplicate
20
21 if not is_executable(self.exec_file):
22 raise Exception("Not executable ? : %s" % self.exec_file)
23
24 def __del__(self):
25 # Try and clean up
26 if self.stdout_file is not None:
27 self.stdout_file.close()
28 if self.stderr_file is not None:
29 self.stderr_file.close()
30
31 if self.sp is not None:
32 try:
33 self.sp.terminate()
34 except OSError as e:
35 if e.errno == 3:
36 pass # no such process (already killed), okay
37 else:
38 raise e
39
40 def __get_full_command(self):
41 full_command = [self.exec_file]
42 if self.extra_args is not None:
43 full_command += self.extra_args
44 return full_command
45
46 def execute(self):
47 """Execute the binary."""
48 full_command = self.__get_full_command()
49 self.sp = subprocess.Popen(full_command, stdout=self.stdout_file,
50 stderr=self.stderr_file, cwd=self.cwd)
51
52 def kill(self):
53 self.sp.kill()
54
55 def interrupt(self):
56 self.sp.send_signal(signal.SIGINT)
57
58 def terminate(self):
59 """Send the terminate signal to the binary."""
60 self.sp.terminate()
61
62 def wait(self):
63 """Wait until the executable is finished, checking return code.
64
65 If the exit status is non-zero, raise an exception.
66
67 """
68
69 self.sp.wait()
70 if self.sp.returncode != 0:
71 print >>sys.stderr, "Non-zero return: %s %s" % (self.exec_file, self.extra_args)
diff --git a/experiment/executable/ftcat.py b/experiment/executable/ftcat.py
new file mode 100644
index 0000000..9966312
--- /dev/null
+++ b/experiment/executable/ftcat.py
@@ -0,0 +1,33 @@
1import os
2import stat
3
4from executable import Executable
5
6class FTcat(Executable):
7 """Used to wrap the ftcat binary in the Experiment object."""
8
9 def __init__(self, ft_cat_bin, stdout_file, stderr_file, dev, events, cpu=None):
10 """Extends the Executable initializer method with ftcat attributes."""
11