diff --git a/expetator/leverages/nodeepsleep.py b/expetator/leverages/nodeepsleep.py index e78c12abd759af22d81d4a1ef2abe4448910a0ea..10c6e6dd93456348e41d2b9ce5e10ae6d449035f 100644 --- a/expetator/leverages/nodeepsleep.py +++ b/expetator/leverages/nodeepsleep.py @@ -9,26 +9,35 @@ def signal_handler(signal_number, frame): os.close(fd) fd = os.open("/dev/cpu_dma_latency", os.O_RDWR) -os.write(fd, b'\0\0\0\0') +os.write(fd, b'\\0\\0\\0\\0') signal.signal(signal.SIGINT, signal_handler) signal.pause() """ +terminate_script = """#!/bin/bash +ps aux | grep script_nodeepsleep.py | grep sudo | awk '{print $2}' | xargs sudo-g5k kill +""" + class Nodeepsleep: 'Activates or deactivates CX' def __init__(self, modes = {True, False}): self.modes = modes self.binary = '/tmp/bin/script_nodeepsleep.py' + self.terminate = '/tmp/bin/terminate_nodeepsleep.py' self.cur_mode = False def build(self, executor): 'Builds the software' self.executor = executor with open(self.binary, 'w') as out_file: - out_file.write(script) + out_file.write(source_script) os.chmod(self.binary, 0o777) + with open(self.terminate, 'w') as out_file: + out_file.write(terminate_script) + os.chmod(self.terminate, 0o777) + def available_states(self): 'Returns all the modes' return self.modes @@ -40,8 +49,9 @@ class Nodeepsleep: self.executor.hosts(self.binary+' &', root=True) def stop(self, output_file=None): - 'Reverts to the maximum frequency' - self.executor.hosts('killall script_nodeepsleep.py', root=True) + 'Stops the script' + if self.curr_mode: + self.executor.hosts(self.terminate, root=True) self.curr_mode = False def get_state(self): diff --git a/setup.py b/setup.py index 6f289778d4312b0d0846de884d8e64b8dc9cd9e5..eded41c37e6725106a54c00322ba44c26a898fad 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="expetator", - version="0.2.3", + version="0.2.5", author="Georges Da Costa", author_email="georges.da-costa@irit.fr", description="A framework for monitoring HPC applications using DVFS",