mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
unix: Allow the GIL to be enabled.
The unix port can now be built with the GIL enabled, by passing MICROPY_PY_THREAD_GIL=1 on the make command line. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -132,7 +132,11 @@ ifeq ($(MICROPY_PY_SOCKET),1)
|
||||
CFLAGS += -DMICROPY_PY_SOCKET=1
|
||||
endif
|
||||
ifeq ($(MICROPY_PY_THREAD),1)
|
||||
ifeq ($(MICROPY_PY_THREAD_GIL),1)
|
||||
CFLAGS += -DMICROPY_PY_THREAD=1 -DMICROPY_PY_THREAD_GIL=1
|
||||
else
|
||||
CFLAGS += -DMICROPY_PY_THREAD=1 -DMICROPY_PY_THREAD_GIL=0
|
||||
endif
|
||||
LDFLAGS += $(LIBPTHREAD)
|
||||
endif
|
||||
|
||||
|
||||
@@ -137,6 +137,9 @@ typedef long mp_off_t;
|
||||
#define MICROPY_STACKLESS_STRICT (0)
|
||||
#endif
|
||||
|
||||
// Recursive mutex is needed when threading is enabled, regardless of GIL setting.
|
||||
#define MICROPY_PY_THREAD_RECURSIVE_MUTEX (MICROPY_PY_THREAD)
|
||||
|
||||
// Implementation of the machine module.
|
||||
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/unix/modmachine.c"
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ MICROPY_PY_BTREE = 1
|
||||
|
||||
# _thread module using pthreads
|
||||
MICROPY_PY_THREAD = 1
|
||||
MICROPY_PY_THREAD_GIL = 0
|
||||
|
||||
# Subset of CPython termios module
|
||||
MICROPY_PY_TERMIOS = 1
|
||||
|
||||
@@ -40,7 +40,12 @@
|
||||
//
|
||||
// Note that we don't delay for the full TIMEOUT_MS, as execution
|
||||
// can't be woken from the delay.
|
||||
#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) mp_hal_delay_us(500)
|
||||
#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) \
|
||||
do { \
|
||||
MP_THREAD_GIL_EXIT(); \
|
||||
mp_hal_delay_us(500); \
|
||||
MP_THREAD_GIL_ENTER(); \
|
||||
} while (0)
|
||||
|
||||
void mp_hal_set_interrupt_char(char c);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
// Send raise KeyboardInterrupt directly from the signal handler rather than
|
||||
// scheduling it into the VM.
|
||||
#define MICROPY_ASYNC_KBD_INTR (1)
|
||||
#define MICROPY_ASYNC_KBD_INTR (!MICROPY_PY_THREAD_GIL)
|
||||
|
||||
// Enable helpers for printing debugging information.
|
||||
#ifndef MICROPY_DEBUG_PRINTERS
|
||||
|
||||
Reference in New Issue
Block a user