1. Threads?

Rob,

I know this has been discussed in the past but is there any plans in the 
near future for thread in Euphoria?

I've recently had occasions where I could use threads in Euphoria, 
particularly for functions that could run a long time (database 
retrieval).

Thanks,

Jonas

new topic     » topic index » view message » categorize

2. Re: Threads?

Jonas Temple writes:
> I know this has been discussed in the past 
> but is there any plans in the near future for 
> thread in Euphoria?

Not in the near future.
There are a lot of thorny issues regarding threads,
and only a small percentage of people would likely use them.
It would be an interesting thing to do at some time.

One thorny problem is the issue of "thread-safe" library routines.
Many C library routines, as well as some Euphoria run-time
routines are not necessarily "thread-safe". For example, if one
thread was executing in the middle of malloc(), and then 
control passed suddenly to another thread which then 
called malloc(), you could corrupt the heap. I think the 
Microsoft compiler has a version of the C run-time 
that is thread-safe, and another (faster one) that isn't.

> I've recently had occasions where I could use threads in Euphoria, 
> particularly for functions that could run a long time (database 
> retrieval).

You can today, run multiple Euphoria *processes*, 
i.e. separate programs, which can communicate 
via files or shared memory. This gives you parallelism, 
but at a coarser level than threads, i.e. the context
switching is slower.

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Threads?

On 9 Oct 2002, at 16:00, Robert Craig wrote:

> 
> Jonas Temple writes:
> > I know this has been discussed in the past 
> > but is there any plans in the near future for 
> > thread in Euphoria?
> 
> Not in the near future.
> There are a lot of thorny issues regarding threads,
> and only a small percentage of people would likely use them.
> It would be an interesting thing to do at some time.
> 
> One thorny problem is the issue of "thread-safe" library routines.
> Many C library routines, as well as some Euphoria run-time
> routines are not necessarily "thread-safe". For example, if one
> thread was executing in the middle of malloc(), and then 
> control passed suddenly to another thread which then 
> called malloc(), you could corrupt the heap. I think the 
> Microsoft compiler has a version of the C run-time 
> that is thread-safe, and another (faster one) that isn't.
> 
> > I've recently had occasions where I could use threads in Euphoria, 
> > particularly for functions that could run a long time (database 
> > retrieval).
> 
> You can today, run multiple Euphoria *processes*, 
> i.e. separate programs, which can communicate 
> via files or shared memory. This gives you parallelism, 
> but at a coarser level than threads, i.e. the context
> switching is slower.

Or use socks. Or DDE (windoze only?). Other than socks or dde, is there 
any way to signal the other process(es) that there is work to be done?

Kat

new topic     » goto parent     » topic index » view message » categorize

4. Re: Threads?

Kat writes:
> Other than socks or dde, is there 
> any way to signal the other process(es) that there is work to be done?

Have a look at Jordah Ferguson's demo where 
processes pass Euphoria data to each other via shared memory.
He uses a library developed by Mario Steele and Jason Mirwald.
I think jbrown was doing something similar on Linux.
A process could sleep() and periodically check a value in 
shared memory.

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: Threads?

On 9 Oct 2002, at 22:56, Robert Craig wrote:

> 
> Kat writes:
> > Other than socks or dde, is there 
> > any way to signal the other process(es) that there is work to be done?
> 
> Have a look at Jordah Ferguson's demo where 
> processes pass Euphoria data to each other via shared memory.
> He uses a library developed by Mario Steele and Jason Mirwald.
> I think jbrown was doing something similar on Linux.
> A process could sleep() and periodically check a value in 
> shared memory.

Sleep()ing isn't the same as an event trigger.

Kat

new topic     » goto parent     » topic index » view message » categorize

6. Re: Threads?

On  0, Kat <kat at kogeijin.com> wrote:
> 
> On 9 Oct 2002, at 22:56, Robert Craig wrote:
> 
> > 
> > Kat writes:
> > > Other than socks or dde, is there 
> > > any way to signal the other process(es) that there is work to be done?
> > 
> > Have a look at Jordah Ferguson's demo where 
> > processes pass Euphoria data to each other via shared memory.
> > He uses a library developed by Mario Steele and Jason Mirwald.
> > I think jbrown was doing something similar on Linux.
> > A process could sleep() and periodically check a value in 
> > shared memory.
> 
> Sleep()ing isn't the same as an event trigger.
> 
> Kat
> 

No, but it comes close to emulating it.

Under *nix, you can also use signals as triggers, signals + shared memory
should od the trick: the signal can be the event trigger and the shared mem
can transfer the variable states shared between processes. (This is what I
tried to do, but I was unable to solve the race condition which tended to
corrupt the database. File locks and mutexes both failed for me, hence I
resorted to socks.)

Is there any similar mechanism to signals under Win32? You could use that
as the event trigger.

jbrown

new topic     » goto parent     » topic index » view message » categorize

7. Re: Threads?

I wrote:
> Under *nix, you can also use signals as triggers, signals + shared memory
> should od the trick: the signal can be the event trigger and the shared mem
> can transfer the variable states shared between processes. (This is what I
> tried to do, but I was unable to solve the race condition which tended to
> corrupt the database. File locks and mutexes both failed for me, hence I
> resorted to socks.)

I should point out that signals are a type of communication between unix
processes. One processes can signal another one, which will then stop whatever
its doing to do run the code for the signal handler. After it returns, then
the signalled program does back to whatever it was doing before.

jbrown

new topic     » goto parent     » topic index » view message » categorize

8. Re: Threads?

Kat writes:
> Other than socks or dde, is there 
> any way to signal the other process(es) that there is work to be done?

Have a look at Jordah Ferguson's demo where 
processes pass Euphoria data to each other via shared memory.
He uses a library developed by Mario Steele and Jason Mirwald.
I think jbrown was doing something similar on Linux.
A process could sleep() and periodically check a value in 
shared memory.

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

new topic     » goto parent     » topic index » view message » categorize

9. Re: Threads?

WOW ,, i just now got this:

On 9 Oct 2002, at 22:56, Robert Craig wrote:

> 
> Kat writes:
> > Other than socks or dde, is there 
> > any way to signal the other process(es) that there is work to be done?
> 
> Have a look at Jordah Ferguson's demo where 
> processes pass Euphoria data to each other via shared memory.
> He uses a library developed by Mario Steele and Jason Mirwald.
> I think jbrown was doing something similar on Linux.
> A process could sleep() and periodically check a value in 
> shared memory.
> 
> Regards,
>    Rob Craig
>    Rapid Deployment Software
>    http://www.RapidEuphoria.com
> 
> 
> 
>

new topic     » goto parent     » topic index » view message » categorize

10. Re: Threads?

I got that on the 9th and today.


On 19 Oct 2002 01:45:38, Kat wrote

>WOW ,, i just now got this:
>
>On 9 Oct 2002, at 22:56, Robert Craig wrote:
>
> >
> > Kat writes:
> > > Other than socks or dde, is there
> > > any way to signal the other process(es) that there is work to be done?
> >
> > Have a look at Jordah Ferguson's demo where
> > processes pass Euphoria data to each other via shared memory.
> > He uses a library developed by Mario Steele and Jason Mirwald.
> > I think jbrown was doing something similar on Linux.
> > A process could sleep() and periodically check a value in
> > shared memory.
> >
> > Regards,
> >    Rob Craig
> >    Rapid Deployment Software
> >    http://www.RapidEuphoria.com

Euphoria Instant Messenger
Have YOU Joined?
http://groups.yahoo.com/group/euim/

new topic     » goto parent     » topic index » view message » categorize

11. Re: Threads?

So did I. Why?

On  0, Elliott Sales de Andrade <quantum_analyst at hotmail.com> wrote:
> 
> 
> I got that on the 9th and today.
> 
> 
> On 19 Oct 2002 01:45:38, Kat wrote
> 
> >WOW ,, i just now got this:
> >
> >On 9 Oct 2002, at 22:56, Robert Craig wrote:
> >
> > >
> > > Kat writes:
> > > > Other than socks or dde, is there
> > > > any way to signal the other process(es) that there is work to be done?
> > >
> > > Have a look at Jordah Ferguson's demo where
> > > processes pass Euphoria data to each other via shared memory.
> > > He uses a library developed by Mario Steele and Jason Mirwald.
> > > I think jbrown was doing something similar on Linux.
> > > A process could sleep() and periodically check a value in
> > > shared memory.
> > >
> > > Regards,
> > >    Rob Craig
> > >    Rapid Deployment Software
> > >    http://www.RapidEuphoria.com
> 
> Euphoria Instant Messenger
> Have YOU Joined?
> http://groups.yahoo.com/group/euim/
> 
> 
> 
> 

Linux User:190064
Linux Machine:84163

--

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu