lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I played a bit with getting multi-threading working. The Lua threads package
is out of date and I think leaks mutexes, but it's a reasonable model of
what one needs to do.

What I noticed was that performance dropped fairly significantly with
multi-threading enabled even though I was actually still just running
single-threaded and there should have been no mutex contention. This was
more significant for code that was interacting heavily with C code because
the majority of transitions across the interface involve acquiring the
mutex. Since some of this is out of concern that the garbage collector needs
the stacks for the states, I am hoping that the incremental GC will reduce
this overhead.

Mark

on 8/12/03 7:36 AM, Michael Bernstein at michael@simoniac.com wrote:

> 
> On Tuesday, August 12, 2003, at 08:45  AM, Phipps Xue wrote:
> 
>> I's there any information about developing a multi-threaded c++
>> application, which will call lua script in each thread?
>> 
>> My demo programm could dance very well in single thread but crashed
>> when
>> I copy the same code snippet in a programm has one main thread and one
>> child thread.
>> 
>> TIA
>> 
>> Xue Jianmin, Phipps
>> 
>> Mobile: 1350-183-1513
>> E-mail: xuejm@sina.com
>> 
>> 
> 
> Are you creating a new instance of the lua interpreter for each thread?
> From what I understand, you need to create independent instances of
> the interpreter.  Most likely, you realize this and are doing so.
> however, there could be a conflict based on the snippet you have
> chosen.  What I would recommend is to write a small snippet that really
> doesn't do anything except open a lua script and grab a few variable
> values, and then print them to stderr or wherever you wish, and fork 3
> or 4 times and have it test this....once you succeed at that, you know
> it's not an issue with your lua calls.  However, if that fails, send
> another post with the code attached or whatnot for the simple test and
> we collectively can see where there could be a problem.
> 
> 
> -----
> 
> Michael Bernstein
> 
> "Until they become conscious they will never rebel, and until after
> they have rebelled they cannot become conscious"
> --George Orwell, 1984
>