Re: Simulating Threads in Eu

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

On  0, Robert Craig <rds at RapidEuphoria.com> wrote:
> 
> 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
> 

I already have the shared memory routines wrapped, and semaphores
should be equally simple. The real problem was how to handle
complex sequences and how to allocate the shared memory dynamicly.
After looking at database.e, I can see how to share Euphoria objects
(although I'd rather modify bget/bprint into mget/print, which seems
simplier) but I still am unclear as how to allocate the memory for
variables
on demand and have all "threads" know about it simultaniously.

Once I can figure out how to do that then I can start coding this
project again.

jbrown



-- 
Faster than the email provider that you're using!
Soar with FastMail.FM! -> http://fastmail.fm

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

Search



Quick Links

User menu

Not signed in.

Misc Menu