diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-16 20:46:19 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-16 20:46:19 -0400 |
commit | bdb33621ac67b2cd9fadf3f3b006419ebb16a713 (patch) | |
tree | 8918b5dbc6db8a73c275e445153c7ea42857210b /experiment/executable/ftcat.py | |
parent | fd92ecb5a642eeae6c54d3cca1508fc4c4cb6a87 (diff) |
Created run_exps.py script.
Currently poorly documented.
Diffstat (limited to 'experiment/executable/ftcat.py')
-rw-r--r-- | experiment/executable/ftcat.py | 33 |
1 files changed, 33 insertions, 0 deletions
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 @@ | |||
1 | import os | ||
2 | import stat | ||
3 | |||
4 | from executable import Executable | ||
5 | |||
6 | class 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 | |||
12 | # hack to run FTCat at higher priority | ||
13 | chrt_bin = '/usr/bin/chrt' | ||
14 | |||
15 | super(FTcat, self).__init__(chrt_bin) | ||
16 | self.stdout_file = stdout_file | ||
17 | self.stderr_file = stderr_file | ||
18 | |||
19 | mode = os.stat(dev)[stat.ST_MODE] | ||
20 | if not mode & stat.S_IFCHR: | ||
21 | raise Exception("%s is not a character device" % dev) | ||
22 | |||
23 | if events is None: | ||
24 | raise Exception('No events!') | ||
25 | |||
26 | # hack to run FTCat at higher priority | ||
27 | self.extra_args = ['-f', '40'] | ||
28 | if cpu is not None: | ||
29 | # and bind it to a CPU | ||
30 | self.extra_args.extend(['/usr/bin/taskset', '-c', str(cpu)]) | ||
31 | events_str_arr = map(str, events) | ||
32 | self.extra_args.extend([ft_cat_bin, dev] + events_str_arr) | ||
33 | |||