In Practical Foundations of Programming Languages by Harper,
Although it is relatively easy to visualize and implement coroutines involving only two partners, it is more complex and less useful to consider a similar pattern of control among n ≥ 2 participants. In such cases, it is more common to structure the interaction as a collection of n routines, each of which is a coroutine of a central scheduler . When a routine resumes its partner, it passes control to the scheduler, which determines which routine to execute next, again as a coroutine of itself. When structured as coroutines of a scheduler, the individual routines are called threads. A thread yields control by resuming its partner, the scheduler, which then determines which thread to execute next as a coroutine of itself. This pattern of control is called cooperative multi-threading, because it is based on voluntary yields, rather than forced suspensions by a scheduler.
What does "a collection of n routines, each of which is a coroutine of a central scheduler" mean:
- a collection of n+1 coroutines, which consist of the n participants and the central scheduler
- n pairs of coroutines, and each pair consists of a participant and the central scheduler?
Regarding the first possibility, the book introduces coroutines as a pair of coroutines before the quote. Is it possible to have a collection of more than two coroutines?