GIL

classic Classic list List threaded Threaded
4 messages Options
Jim
Reply | Threaded
Open this post in threaded view
|

GIL

Jim
i recently learned that the CPython interpreter uses a
global interpreter lock. i suppose Lua does not, right ?

Reply | Threaded
Open this post in threaded view
|

Re: GIL

Ilya Shchukin
Lua itself doesn't have threads that run concurrently, what it has is coroutines, that is a form of cooperative multitasking - you manage when to yield. Hovewer, most common type of thread implementation is mutexing Lua state, and it is equivalent to GIL. You are better to run multiple Lua states (that communicate via host code) concurrently rather running your threads in the same single Lua state.

Ilya Shchukin

On Wed, May 22, 2019, 9:06 PM Jim <[hidden email]> wrote:
i recently learned that the CPython interpreter uses a
global interpreter lock. i suppose Lua does not, right ?

Reply | Threaded
Open this post in threaded view
|

Re: GIL

Sean Conner
In reply to this post by Jim
It was thus said that the Great Jim once stated:
> i recently learned that the CPython interpreter uses a
> global interpreter lock. i suppose Lua does not, right ?

  Not one by default.  And as long as you keep on system thread, one Lua
state, there is no need for one.  If, however, you want to share a Lua state
among system threads, you'll need to recompile Lua with an implementation
for the two given functions:

        lua_lock()
        lua_unlock()

(right now they're do-nothing macros)

  -spc


Reply | Threaded
Open this post in threaded view
|

Re: GIL

云风 Cloud Wu
In reply to this post by Jim


Jim <[hidden email]>于2019年5月23日 周四02:06写道:
i recently learned that the CPython interpreter uses a
global interpreter lock. i suppose Lua does not, right ?

Yes, you can run multi lua vm in different thread, each one is independent, no global lock.

Pyhton has GIL problem, so there is a global lock even you run multi python vm (for multi task), it’s inefficient.

Lua has no GIL problem, but you should use multi vm for multithreading.



--