News for hackers. Stuff that matters.
Re:Libaco: A fast and lightweight C asymmetric coroutine lib... by otabdeveloper2 on Saturday July 14, 2018 @02:54PM (#17531757)
> First, context-switching in coroutines is at least a thousand times faster than with threads.

You misunderstand how context switching works. It doesn't matter how many threads you have -- 5 or 5000. Your OS will switch contexts at a constant rate.

What you perceive as 'context switch overhead' is really process scheduling being too smart for its own good.

99% of the time the problem is solved with a simple round-robin process scheduler. (Called a 'realtime' scheduler in Linux.)

> it is common to see multithreaded applications spending more CPU time on context-switching than actually running application code

No. Like I said, context switching is constant-time overhead for your OS.

There are no comments on this comment yet.