1

I read that Python2 used a bytecode counter to decide when the GIL should switch execution between threads but that Python3 uses a timer.

I am wondering, how does the context switching process work? In particular how does the timer interrupt save the current context of the thread and switch to another thread?

In embedded systems this pretty straightforward but it's unclear to me how the python interpreter works with the OS to achieve this while keeping the context of the current thread intact.

FourierFlux
  • 439
  • 5
  • 13
  • No, that focuses on the python language - I am interested in how the interpreter actually achieves it. Particularly since as far as I know, you can't easily implement your own context switcher in windows or linux. – FourierFlux Apr 26 '21 at 01:48

0 Answers0