summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-05-26 10:42:53 +0000
committerDamien George <damien.p.george@gmail.com>2016-06-28 11:28:50 +0100
commit4cec63a9dbed86c4332b9e7fcd56d092046193e4 (patch)
tree9e5e0636411f5de6647d4021c8069a39cb031f14 /py/runtime.c
parent1f54ad2aed0dc8f2d868ccd89ccf639a475e8022 (diff)
py: Implement a simple global interpreter lock.
This makes the VM/runtime thread safe, at the cost of not being able to run code in parallel.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 7f28abbf4..f88c92be6 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -91,6 +91,12 @@ void mp_init(void) {
// start with no extensions to builtins
MP_STATE_VM(mp_module_builtins_override_dict) = NULL;
#endif
+
+ #if MICROPY_PY_THREAD_GIL
+ mp_thread_mutex_init(&MP_STATE_VM(gil_mutex));
+ #endif
+
+ MP_THREAD_GIL_ENTER();
}
void mp_deinit(void) {