From 4cec63a9dbed86c4332b9e7fcd56d092046193e4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 26 May 2016 10:42:53 +0000 Subject: 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. --- py/runtime.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'py/runtime.c') 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) { -- cgit v1.2.3