aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-08-26 16:00:09 +0200
committerKarel Kočí <cynerd@email.cz>2015-08-26 16:00:09 +0200
commite5d612529a1e9e2e12d0c5a322821e7dbb175be6 (patch)
tree337e9e8974a563e0ba08831cabd48c3bb63f453e
parent8b0ebe5a478fae92a49f12b5ac6090ba9d15bcbb (diff)
downloadlinux-conf-perf-e5d612529a1e9e2e12d0c5a322821e7dbb175be6.tar.gz
linux-conf-perf-e5d612529a1e9e2e12d0c5a322821e7dbb175be6.tar.bz2
linux-conf-perf-e5d612529a1e9e2e12d0c5a322821e7dbb175be6.zip
Fix multithreading
-rwxr-xr-xscripts/loop.py34
1 files changed, 14 insertions, 20 deletions
diff --git a/scripts/loop.py b/scripts/loop.py
index d464e30..ad87f18 100755
--- a/scripts/loop.py
+++ b/scripts/loop.py
@@ -48,19 +48,7 @@ def measure(kernelimg, con):
boot.boot(con)
print("Configuration '" + con.hash + "' measured.")
-# Threads #
-__terminate__ = False
-class mainThread(Thread):
- def run(self):
- if conf.single_loop:
- img, config = prepare()
- measure(img, config)
- else:
- while not __terminate__:
- img, config = prepare()
- measure(img, config)
-
-# Multithread section #
+# Multithread #
__conflist__ = set()
__listlock__ = Lock()
@@ -102,19 +90,25 @@ __measurethread__ = measureThread()
def sigterm_handler(_signo, _stack_frame):
__terminate__ = True
+# Main loop and single thread #
def loop():
utils.dirtycheck()
initialize.all()
- global thr
- thr = mainThread()
- thr.start()
- try:
- thr.join()
- except KeyboardInterrupt:
- __terminate__ = True
+ if conf.multithread:
+ __preparethread__.start()
+ __measurethread__.start()
+ else:
+ if conf.single_loop:
+ img, config = prepare()
+ measure(img, config)
+ else:
+ while not __terminate__:
+ img, config = prepare()
+ measure(img, config)
#################################################################################
if __name__ == '__main__':
signal.signal(signal.SIGTERM, sigterm_handler)
+ signal.signal(signal.SIGINT, sigterm_handler)
loop()