aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2019-01-10 15:43:47 +1100
committerDamien George2019-01-10 15:43:47 +1100
commitefe0569c260677ac480d8958616f046b992ec6d8 (patch)
tree629568e132640e9da2c3fe0e8ecc6be2191087ce
parentafecc124e6a9bb905acae963d759b60ed9ec4f71 (diff)
esp32/mphalport: When tx'ing to REPL only release GIL if many chars sent
Otherwise, if multiple threads are active, printing data to the REPL may be very slow because in some cases only one character is output per call to mp_hal_stdout_tx_strn.
-rw-r--r--ports/esp32/mphalport.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c
index aa79c878e..7992c8ded 100644
--- a/ports/esp32/mphalport.c
+++ b/ports/esp32/mphalport.c
@@ -61,11 +61,17 @@ void mp_hal_stdout_tx_str(const char *str) {
}
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
- MP_THREAD_GIL_EXIT();
+ // Only release the GIL if many characters are being sent
+ bool release_gil = len > 20;
+ if (release_gil) {
+ MP_THREAD_GIL_EXIT();
+ }
for (uint32_t i = 0; i < len; ++i) {
uart_tx_one_char(str[i]);
}
- MP_THREAD_GIL_ENTER();
+ if (release_gil) {
+ MP_THREAD_GIL_ENTER();
+ }
mp_uos_dupterm_tx_strn(str, len);
}