Re:Show HN: Coros – A Modern C++ Library for Task Parallelism
by loeg on Wednesday September 25, 2024 @01:01PM
(#41649476)
They're just green threads with some nice syntax sugar, right? Instead of an OS-level "pause" with a futex-wait or sleep (resumed by the kernel scheduler), they do an application-level pause and require some application-level scheduler. (But coroutines can still call library or kernel functions that block/sleep, breaking userspace scheduling?)
[ Parent
| on HN ]
Re:Show HN: Coros – A Modern C++ Library for Task Parallelism
by singledigits on Wednesday September 25, 2024 @05:02PM
(#41651837)
Yes, exactly. Coroutines are one possible implementation of green threads. Once they are scheduled/loaded on an OS thread, they behave just like regular functions with their own call stack. This means they can indeed call blocking operations at the OS level. A possible approach to handle such operations would be to wrap the blocking call, suspend the coroutine, and then resume it once the operation is complete, perhaps by polling(checking for completion).