beremiz

Parents 55ed9df633d4
Children 8cc70f7f525a
Attempt (disabled) to systematically attach a cobalt shadow thread to python threads.
When experimenting with pthread_cond, didn't see any enhancement.
--- a/runtime/xenomai.py Fri Dec 06 11:45:03 2019 +0100
+++ b/runtime/xenomai.py Mon Dec 09 09:42:07 2019 +0100
@@ -7,6 +7,22 @@
from __future__ import absolute_import
from ctypes import CDLL, RTLD_GLOBAL, pointer, c_int, POINTER, c_char, create_string_buffer
+import threading
+
+def installThreadCobaltHook():
+ init_old = threading.Thread.__init__
+
+ def init(self, *args, **kwargs):
+ init_old(self, *args, **kwargs)
+ run_old = self.run
+
+ def run_with_shadow(*args, **kw):
+ print("hello from thread"+repr(self))
+ cobalt.cobalt_thread_harden()
+ run_old(*args, **kw)
+ self.run = run_with_shadow
+ threading.Thread.__init__ = init
+
def TryPreloadXenomai():
"""
@@ -22,4 +38,6 @@
globals()[name] = CDLL("lib"+name+".so", mode=RTLD_GLOBAL)
cobalt.xenomai_init(pointer(c_int(0)), pointer((POINTER(c_char)*2)(create_string_buffer("prog_name"), None)))
except Exception:
- pass
+ return
+
+ # installThreadCobaltHook()