Search code examples
multithreadingluamulticorelua-lanes

Lua Lanes and multi-core support: Can it be done?


Lua Lanes says that it enables multi-core support through multithreading. Isn't this incorrect? Don't you need to use multiple processes to take advantage of multiple cores? Does Lua Lanes do this?

Perhaps I'm misinterpreting what they're saying. Here's the passage from their site:

Lua Lanes is a Lua extension library providing the possibility to run multiple Lua states in parallel. It is intended to be used for optimizing performance on multicore CPU's and to study ways to make Lua programs naturally parallel to begin with.

Thanks


Solution

  • It depends on the operating system, but most current operating systems (Windows, Linux/*nix, ...) distribute tasks onto cores/CPUs by threads, not by processes. So a single process with multiple threads can be run on multiple cores.

    Lanes uses real OS threads, not the lightweight Lua threads - coroutines, so the scheduler can actually distribute it onto multiple cores.