Coroutining is how processes and threads are implemented in operating systems (e.g. Linux, Windows, MacOS, etc.).
When the concept of operating systems was invented, we didn't know about the concept of anonymous functions, closures, lambdas, etc. (Actually, lambdas were introduced by Lisp 1.5 in the 1950s, but Lisp was roundly ignored at the time due to concerns about "efficiency").
An O/S contains a list of closures (threads, processes). It implements a function often called a Dispatcher. The Dispatcher picks a closure and coroutines with it ("calls" it), giving it a bit of time to run.
The hardware contains a timer, which interrupts the running closure and makes it "return" to the Dispatcher, which then picks another closure to run from its list of closures, and so on.
We could re-implement the concept of "operating systems" using closures using 2025 languages instead of 1960s languages, but that would <cynicism> make everything much simpler </cynicism>.
If one is interested in this, the fundamental code can be found in Holt’s book, chapter 10.
See Also
Email: ptcomputingsimplicity@gmail.com
References: https://guitarvydas.github.io/2024/01/06/References.html
Blog: guitarvydas.github.io
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/65YZUh6Jpq
Leanpub: [WIP] https://leanpub.com/u/paul-tarvydas
Twitter: @paul_tarvydas
Substack: paultarvydas.substack.com