aboutsummaryrefslogtreecommitdiffstats
path: root/run/litmus_util.py
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-04-12 11:30:27 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2013-04-12 11:30:27 -0400
commit09bc409657606a37346d82ab1e4c44a165bd3541 (patch)
tree72c569f69f37acafdc89fde4724bde7b373ef8f9 /run/litmus_util.py
parent384e322f974534c1c734db144633e3c3e002b1f8 (diff)
Improved error handling in run_exps.py.
Diffstat (limited to 'run/litmus_util.py')
-rw-r--r--run/litmus_util.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/run/litmus_util.py b/run/litmus_util.py
index 4709b66..70da262 100644
--- a/run/litmus_util.py
+++ b/run/litmus_util.py
@@ -3,6 +3,11 @@ import time
3import subprocess 3import subprocess
4import config.config as conf 4import config.config as conf
5 5
6def scheduler():
7 with open('/proc/litmus/active_plugin', 'r') as active_plugin:
8 cur_plugin = active_plugin.read().strip()
9 return cur_plugin
10
6def switch_scheduler(switch_to_in): 11def switch_scheduler(switch_to_in):
7 '''Switch the scheduler to whatever is passed in. 12 '''Switch the scheduler to whatever is passed in.
8 13
@@ -18,11 +23,10 @@ def switch_scheduler(switch_to_in):
18 # it takes a bit to do the switch, sleep an arbitrary amount of time 23 # it takes a bit to do the switch, sleep an arbitrary amount of time
19 time.sleep(2) 24 time.sleep(2)
20 25
21 with open('/proc/litmus/active_plugin', 'r') as active_plugin: 26 cur_plugin = scheduler()
22 cur_plugin = active_plugin.read().strip()
23
24 if switch_to != cur_plugin: 27 if switch_to != cur_plugin:
25 raise Exception("Could not switch to '%s' (check dmesg)" % switch_to) 28 raise Exception("Could not switch to '%s' (check dmesg), current: %s" %\
29 (switch_to, cur_plugin))
26 30
27def waiting_tasks(): 31def waiting_tasks():
28 reg = re.compile(r'^ready.*?(?P<READY>\d+)$', re.M) 32 reg = re.compile(r'^ready.*?(?P<READY>\d+)$', re.M)
@@ -35,6 +39,17 @@ def waiting_tasks():
35 39
36 return 0 if not ready else int(ready) 40 return 0 if not ready else int(ready)
37 41
42def all_tasks():
43 reg = re.compile(r'^real-time.*?(?P<TASKS>\d+)$', re.M)
44 with open('/proc/litmus/stats', 'r') as f:
45 data = f.read()
46
47 # Ignore if no tasks are waiting for release
48 match = re.search(reg, data)
49 ready = match.group("TASKS")
50
51 return 0 if not ready else int(ready)
52
38def release_tasks(): 53def release_tasks():
39 try: 54 try:
40 data = subprocess.check_output([conf.BINS['release']]) 55 data = subprocess.check_output([conf.BINS['release']])