hnes / libaco

A blazing fast and lightweight C asymmetric coroutine library 💎 ⛅🚀⛅🌞
https://libaco.org
Apache License 2.0
3.49k stars 392 forks source link

Do libaco coroutines run on different CPUs at the same time. i.e. does the program performance benefit from having multiple CPUs #52

Open poetaman opened 2 years ago

poetaman commented 2 years ago

Do libaco coroutines run on different CPUs at the same time. i.e. does the program performance benefit from having multiple CPUs? Or do coroutines run on only one CPU at any given point of time. In that case, libaco could used in conjunction to a standard threading library I guess...

hnes commented 2 years ago

Do libaco coroutines run on different CPUs at the same time. i.e. does the program performance benefit from having multiple CPUs?

Nope. At least not yet.

Or do coroutines run on only one CPU at any given point of time. In that case, libaco could used in conjunction to a standard threading library I guess...

Yes.

libaco currently is only a C coroutine library and has no feature-rich scheduler yet.

praisethemoon commented 2 years ago

Hi there! I just wish to extend on @hnes answer and elaborate a bit, coroutines are not thread or parallel processes. They allow "routines" to be executed concurrently for example, say you have two coroutines, the programmer can have the freedom to run some parts of the first one followed by some parts of the second one then finish the first one later etc. I recommand the following readings for more information: https://stackoverflow.com/questions/1934715/difference-between-a-coroutine-and-a-thread and https://stackoverflow.com/questions/7224625/what-are-the-benefits-of-coroutines.