[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua: Multithreading, Precompiled Chunks
- From: cassino (Carlos Cassino)
- Date: Mon, 9 Mar 1998 08:03:51 -0300
I made the multithreaded changes in Lua. I just splited the
main data structure that Lua uses to save the state in two
parts: one global (common to all threads) and one specific to
each thread (stack, basically).
The major change is in the garbage collector: mark&sweep must
traverse all stacks and I decided to stop all threads at this
moment. This synchronization implies that all threads must
check for GC to enable it to occur. It's really a drawback
but I haven't found a better way...
It's implemented using pthreads library and tested in Linux
and Solaris platforms only. I can make the source available.
The following functions were added to the C API:
- to be called from a new thread, creates a new LuaThread
and associates it to the calling thread.
void lua_threadfunction(lua_Object f, lua_Object p)
- starts a new LuaThread by executing function f with
In Lua the following functions were added:
- behaves like the C function lua_threadfunction.
- receives nothing and returns a new mutex.
- receives a mutex and locks it. Returns nothing.
- receives a mutex an unlocks it. Returns nothing.
- receives a mutex and destroys it. Returns nothing.