Learning paths / Under the scheduler
Under the scheduler
The GIL, virtual threads, a starved pool, preemption, and who gets the P.
- Why Python threads don't run in parallel (the GIL)Python · BasicsTwo threads crunch numbers. They take turns holding the GIL, so only one core is ever busy.
- threading vs multiprocessing vs asyncioPython · BasicsTwo jobs, each a network fetch and then CPU work. With threads, the fetches overlap but the CPU work takes turns on the GIL.
- Virtual threadsJava · AdvancedThree virtual threads share two real (carrier) threads. When one blocks, it steps off its carrier so another can run.
- When parallelStream starves the common poolJava · AdvancedA parallel stream of blocking calls fills the common pool. An unrelated quick task waits in line behind it.
- Can a busy loop starve other goroutines?Go · AdvancedOne P, and main spins in a loop with no function calls. The runtime still interrupts it, so the ticker gets its turns.
- Who gets the P when a goroutine blocks in a syscall?Go · Advancedmain blocks in read() on a plain pipe. Its OS thread waits in the kernel, and Go hands the P to another thread so the ticker keeps running.