Re: Simulating Threads in Eu

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

jbrown writes:
> I still am unclear as how to allocate the memory for variables
> on demand and have all "threads" know about it simultaniously.

You can set up a heap in shared memory, and write your
own storage allocator for variable-sized blocks of memory.
It would look a lot like C's malloc() and free(), although
you should try to do a simple version to start with.
Each Euphoria process would have a copy of your routines for
allocating and freeing shared memory. You would definitely
need to do a semaphore operation at the entry and exit points of
your allocate() and free() routines to prevent multiple processes from
messing around with the heap at the same time. The control
variables for the heap, such as the pointer to the list of free blocks,
would be stored at known fixed offsets from the start of shared memory.

I did something like this on Unix a long time ago (before Euphoria).
It was lots of fun, but I don't have the C code anymore.

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