← index #15456Issue #7662
Related · high · value 0.173
QUERY · ISSUE

docs: explain optional global-interpreter-lock

openby mw66opened 2024-07-12updated 2024-09-01
docs

Documentation URL

https://micropython.org/

Description

I saw this on the homepage:

multithreading via the "_thread" module, with an optional global-interpreter-lock (still work in progress, only available on selected ports)

My question:

So by default micropython does not have GIL? then does it use native multithreading instead of green thread? E.g on a Linux multicore machine?

And how to do mutex between different native threads?

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

ESP32: long hardware SPI transfers unnecessarily holding up other threads

closedby jonathanhoggopened 2021-08-14updated 2021-08-16
port-esp32

The ESP32 hardware SPI implementation spends most of its time just waiting for the hardware to indicate that a transfer is complete. When doing a lot of large transfers (as I do), this means the processor spends a lot of time idle.

I tried shoving the write loop onto a thread but discovered that it makes no difference. Digging into my code (since this bit is my fault now) I realised that I'm not releasing the GIL when waiting on transactions. Adding MP_THREAD_GIL_EXIT/MP_THREAD_GIL_ENTER calls around the waits improves my frame rate by an extraordinary 3x, since my code can now get on with other stuff while the SPI transfers are done.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied