/ THE IDEA
The operating system, the software managing the computer, saves the outgoing thread’s execution state: its instruction position and small working values inside the processor, the part executing instructions. It selects another ready thread, restores that thread’s saved state, and continues from there. There can also be indirect costs. The new thread may need different data in the processor’s small, fast stores of recently used information. Replacing useful data takes time, even after the basic handover has finished. Switching between separate processes, running programmes with their own memory views, can involve additional memory-management changes.
THE FORMAL IDEA
useful fraction = q / (q + s)
| q is useful computation per turn, measured here in microseconds. One microsecond, written µs, is one millionth of a second. | | s is the assumed handover cost in the same unit. The ratio has no units. Multiplying by 100 converts it to a percentage in this toy model. |
|
RUN THE TINY EXAMPLE
Change one thing. Predict what happens.
Let q = 100 µs of useful work and s = 5 µs of switching. Useful fraction = 100 / 105 ≈ 0.952, or 95.2%. Change only the turn length to q = 10 µs. Useful fraction = 10 / 15 ≈ 0.667, or 66.7%.
|
The invented five-microsecond handover now occupies a much larger share of each cycle. No individual instruction became slower; the programme simply pays the fixed assumed handover cost more often relative to useful work.
/ SO WHAT?
Longer turns are not an unconditional improvement. A music or interface thread might need another turn promptly. The practical tradeoff is responsiveness against overhead, which is why measuring both completion time and delays matters when adjusting worker counts or scheduling policies. More runnable workers can mean more contention without more useful processing capacity.
ONE CAVEAT |
| The numbers are illustrative, not a measured switching cost for any computer. Real scheduling does not always use equal turns, and some switches are valuable because the outgoing thread was waiting rather than computing. |
KEEP THIS
When useful turns shrink while handover cost stays similar, coordination consumes a larger fraction of the available processing time.
|
NEXT: How a small piston can lift a large load
|