lua-users home
lua-l archive

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


You want some sort of shared memory space, 

Under Win32 threads can have there own copys of global variables, called
thread local storage (TLS)
I think you could declare 
 extern lua_State *lua_state;
as TLS and have each thread running an independant lua VM, each with its own
variables.

You would have to 
 lua_setstate (lua_State *st);
to your shared state before any thread accessed the shared area, and this
make the threads own state inacessable, not very
useful...hmm

You will probably end up having to write some C extension functions, called
shared_var_get,shared_var_set which copy
variables between the shared state and the local state.

What would be nice ( on a low level ) is if we could map areas of the VM
address space so they were shared between states,
sort of like what MVS does.

As for UNIX...

lyndon

> -----Original Message-----
> From:	Dan Marks [SMTP:dmarks@dionysus.phs.uiuc.edu]
> Sent:	Wednesday, October 14, 1998 2:31 PM
> To:	Multiple recipients of list
> Subject:	lua dictionary mechanism
> 
> 
> Is it possible to use the lua dictionary mechanism to keep a data
> space that is separate from the global variables in lua?  I would like
> to create a separate variable namespace that is accessible from
> several currently running lua threads.  To do this, I wanted to create
> a new kind of lua_tag that would have the settable/gettable redefined
> to retrieve the objects from this new table, so that many lua instances
> could retrieve this data from the same namespace.
> 
> I was thinking of creating a separate lua interpreter instance that would
> be for just storing global variables, and then I would just use a 
> semaphore to block so that only one other thread could access it at once.
> But then I have to duplicate the variable instance to prevent lua_Objects
> from this instance to being passed back to other threads, which would
> no longer synchronize on the semaphore used to prevent concurrent access.
> 
> Maybe this will just have to wait for a multithreaded lua. ?
> 
> Dan
> 
> Dan Marks
> dmarks@uiuc.edu