Global Interpreter Lock in Python

Photo by regularguy.eth on Unsplash
Threads in a ready queue ordered by Operating System’s scheduler ready to perform task in an available processor.
Threads are assigned to processors to perform a task.
Four threads in a ready queue.
Thread 4 executing on a processor, rest three threads are moved to a waiting queue.
After some time period, there will be an interruption or the executing thread is waiting for I/O.
The executing thread and threads on waiting queue are moved back to a ready queue. One of the three thread from the waiting queue will be chosen to execute and rest other will be moved to waiting queue.
start...
end...
sum from 1..10000 is 49995000.
Took 0.000663 seconds.
start...
start...
end...
end...
sum from 1..5000 is 12497500.
sum from 5001..10000 is 37492500.
Took 0.001007 seconds.

--

--

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store