diff options
Diffstat (limited to 'run/litmus_util.py')
-rw-r--r-- | run/litmus_util.py | 23 |
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 | |||
3 | import subprocess | 3 | import subprocess |
4 | import config.config as conf | 4 | import config.config as conf |
5 | 5 | ||
6 | def scheduler(): | ||
7 | with open('/proc/litmus/active_plugin', 'r') as active_plugin: | ||
8 | cur_plugin = active_plugin.read().strip() | ||
9 | return cur_plugin | ||
10 | |||
6 | def switch_scheduler(switch_to_in): | 11 | def 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 | ||
27 | def waiting_tasks(): | 31 | def 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 | ||
42 | def 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 | |||
38 | def release_tasks(): | 53 | def release_tasks(): |
39 | try: | 54 | try: |
40 | data = subprocess.check_output([conf.BINS['release']]) | 55 | data = subprocess.check_output([conf.BINS['release']]) |