lua-users home
lua-l archive

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


It's fairly simple to modify lua to use allocation routines other than 
malloc/free; just supply a function to allocate memory in the shared region, 
and you should be fine.

Ben

----- Original Message -----
From: George Sealy <george@arl.co.nz>
Date: Saturday, March 13, 2004 5:21 pm
Subject: Lua shared between processes

> Hi all,
> 
> I've been experimenting with Lua for work, and have found it to be just 
> the tool I was looking for.  However, I have a problem that I was hoping 
> someone may be able to help me with.
> 
> I need to have multiple processes running on a single machine (Win32), 
> all with access to a single instance of a "world state", which I want to 
> describe with Lua.  My initial solution was to use shared memory in a 
> dll, which would allow all processes to access the single set of data.  
> However, when I use lua_open to create a new state, I can't see a way to 
> make that pointer be in shared memory...  Initially I thought I could 
> create a copy of the Lua state variable, but that'll fall over 
> internally whenever Lua needs more memory.
> 
> The only other option I can think of is some form of communication 
> between processes, such as TCP/IP or memory mapping, but the world state 
> needs to be accessed many (hundreds or even thousands of) times a 
> second, so performance is an issue.
> 
> If anyone has any advice, I'd really appreciate it.  I'd rather avoid 
> rewriting the entire language's memory allocation if I can help it!
> 
> Thanks,
> 
> George Sealy
> 
> -- 
> George Sealy, PhD                       email : george@arl.co.nz
> Software Developer / Architect          phone : +64 3 477 2995
> Animation Research Ltd
> 
>