Skip to content

_thread context switching. #10135

Discussion options

You must be logged in to vote

I guess there are four main cases: STM32, ESP32, RP2040, Unix, but really these fall into two categories:

  • STM32 & ESP32 (pre-emptive, single-core, GIL)
  • RP2040 (multi-core, non-pre-emptive, no GIL) & Unix (multi-core, pre-emptive, no GIL)

Neither of these provide a guarantee that context switches occur at Python instruction boundaries. (I don't think what @dlech said is quite right -- on STM32 there are three mechanisms that can trigger a context switch: pre-emptive (via systick expiring the time slice), lock acquisition, and the various event poll hook and VM hooks. His answer only applies to the last two. The systick-triggered switches can occur at any time).

However, the GIL effective…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by peterhinch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants