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.
This commit is contained in:
Damien George
2016-05-26 10:42:53 +00:00
parent 1f54ad2aed
commit 4cec63a9db
6 changed files with 35 additions and 0 deletions

View File

@@ -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) {