diff options
| author | David Lechner | 2020-01-22 18:14:03 -0600 |
|---|---|---|
| committer | Damien George | 2020-01-26 23:21:29 +1100 |
| commit | fee7e5617f55b4778de74ee185fcc3950cdc7b6d (patch) | |
| tree | 9a1fec68969ee8e27e74a5e92761ae1a194580bb /ports/unix/mpconfigport.h | |
| parent | 96716b46e1c4945d3fe08d9ba91920ca28f9c986 (diff) | |
unix: Release GIL during all system calls.
Addition of GIL EXIT/ENTER pairs are:
- modos: release the GIL during system calls. CPython does this as well.
- moduselect: release the GIL during the poll() syscall. This call can be
blocking, so it is important to allow other threads to run at this time.
- modusocket: release the GIL during system calls. Many of these calls can
be blocking, so it is important to allow other threads to run.
- unix_mphal: release the GIL during the read and write syscalls in
mp_hal_stdin_rx_chr and mp_hal_stdout_tx_strn. If we don't do this
threads are blocked when the REPL or the builtin input function are used.
- file, main, mpconfigport.h: release GIL during syscalls in built-in
functions that could block.
Diffstat (limited to 'ports/unix/mpconfigport.h')
| -rw-r--r-- | ports/unix/mpconfigport.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index f435c3ff3..2f01aff0f 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -285,7 +285,12 @@ void mp_unix_mark_exec(void); #if MICROPY_PY_OS_DUPTERM #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) #else -#define MP_PLAT_PRINT_STRN(str, len) do { ssize_t ret = write(1, str, len); (void)ret; } while (0) +#define MP_PLAT_PRINT_STRN(str, len) do { \ + MP_THREAD_GIL_EXIT(); \ + ssize_t ret = write(1, str, len); \ + MP_THREAD_GIL_ENTER(); \ + (void)ret; \ +} while (0) #endif #ifdef __linux__ |
