Skip to content
Snippets Groups Projects
Commit efe0569c authored by Damien George's avatar Damien George
Browse files

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.
parent afecc124
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment