Hacker News new | ask | show | jobs
by tommiegannert 1190 days ago
There can be several fibers ready to run, e.g. if a mutex or condition variable is being waited on by multiple fibers. You still have to choose which one to run next. If you choose wisely, you might, e.g. be able to free up memory from closures that go out of scope quicker than others.

Think of a data-shuffling pipeline that also updates statistics (in the background): running the next stage of the pipeline is more likely to get rid of lots of memory chunks than is running the statistics code. It also improves pipeline latency, of course. The scheduling definitely matters even for cooperative threading.

1 comments

You're right and I was wrong to say that a scheduler isn't needed. I assume a fiber scheduler is usually much simpler than a thread scheduler though, since it just needs to decide which fiber to run, rather than how long to run a thread for and where.