guile-user
[Top][All Lists]
Advanced

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

RE: Difficult Problem


From: Crowder, Brian
Subject: RE: Difficult Problem
Date: Thu, 23 Aug 2001 10:28:36 -0700

Okay, well...  I was able to make this work by kludging in some goo in the
thread spawn for the one thread which will run guile....  I'd still
optimally rather have multiple guile-threads, but that's fine for now.  :)
It turns out, it needn't be the main thread.  You can run gh_enter() from
any thread, as long as it happens earlier in the stack than any other guile
goodness.

Anyway, thanks for the help, guys.  :)

--Brian

-----Original Message-----
From: Bill Gribble [mailto:address@hidden
Sent: Wednesday, August 22, 2001 4:36 PM
To: Crowder, Brian
Cc: address@hidden
Subject: Re: Difficult Problem


On 22 Aug 2001 15:56:55 -0700, Crowder, Brian wrote:
> Any suggestions on making this work, or am I on crack?

Disclaimer: I haven't done any of this, and I can't make any guarantees.
But I have done Scheme and multithreaded C++ in the same app.  Rob
Browning will probably pipe up on this too. 

Guile doesn't know anything about your threads, and you have to be nice
to it on that account.  In particular, Guile uses a conservative
stack-scanning garbage collector, meaning that the stacks of most
threads will be out of its realm of knowledge.  You should only
call guile functions from the thread that called "gh_enter" at the 
beginning of the program, namely the "main" thread.

You can do this nice and safely by maintaining a global queue of forms
to be evaluated with completion callbacks or some other way of
un-blocking threads that wanted guile forms evaluated.  i.e. instead of
using gh_eval_str in your threads, you push the string arg onto a queue
that gets serviced by the thread that's "authorized" to use guile (by
virtue of being the one that called gh_enter), and along with each
string you push some info (maybe a mutex pointer) that will allow the
Guile thread to signal the other thread that it's done with the
gh_eval_str.

Does that make sense? 

b.g.








reply via email to

[Prev in Thread] Current Thread [Next in Thread]