Lua :: How to write a simple program that will load multiple processors?

I could not write a program in Lua that will load more than one processor. Since Lua supports this concept through coroutines , I believe that it is achievable.

The reason for me may be one of:

  • This is not possible in Lua
  • I can’t write it ☺ (and I hope in this case)

Can someone more experienced (I discovered Lua two weeks ago) point me in the right direction?


The point is to write a number-crunching script that does hi-load on ALL cores... For demonstration purposes, the power of Lua.

Thank...

+5
source share
6 answers

Lua coroutines - , .

. , , -, . , . , .

Lua coroutines . Coroutines "thread", . , coroutine , coroutine.yield. , , coroutine.resume .

Lua coroutines , co. . , , .

, , Lua, . , Lua instance. API Lua ; , Lua. Lua, Lua, , .

Lua Lua . Lua-ltreads Lua ; API , , . LuaLanes .

+7

Lua- ( /), , Lua .

jpjacobs LuaLanes, , , . ( .)

Lua , , , , - .

+6

LuaLanes, llthreads

+2

LuaLanes, llthreads , , .

POSIX, posix.fork() ( luaposix). , , , , , .

, , LuaJIT 2, .

+1

Lua lua .

Lua - . , c- IPC.

0

, IPC, .

If you program in an object-oriented language such as C ++, it is possible that multiple threads can access shared objects through threads using object pointers, it is simply unsafe if you do not provide any guarantee that there are no two streams will try to read and write the same data at the same time.

There are many options for how you can do this; locking and waiting mechanisms are becoming increasingly popular.

0
source

All Articles