Re: Simulating Threads in Eu

new topic     » goto parent     » topic index » view thread      » older message » newer message

jbrown writes:
> I'm trying to figure out how to simulate
> threads in Eu, under Linux fork() does what I need
> but the problem is with sharing veriables.

Linux (Unix) shared memory is probably what you are looking for.
(type:  man shmat)

That would give multiple Euphoria processes a fast way
of sharing data in memory, at a low level via peeks and pokes.
If you want to share complex sequences, you could easily adapt the
compress() and decompress() routines in database.e to
convert any Euphoria sequence or atom to/from a string of bytes in memory.
You could pre-allocate the data or write a storage allocator to
give out blocks of shared memory on demand. 
Concurrency issues (critical sections) can be handled 
using UNIX semaphores (man semget). Processes would
have to call a routine whenever they wanted to read or 
write a "variable" in shared memory, but it would be much faster
than using files.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu