[Top][All Lists]

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

Integrating guile into an existing multi-threaded application

From: Charlie Root
Subject: Integrating guile into an existing multi-threaded application
Date: Tue, 4 Jun 2002 22:53:17 -0700 (PDT)


Yes, another pthread question. I've been through the list archives,
read what docs there are, looked a bit at the code, and had a few
questions answered. But before I take off in the wrong direction, I'd
appreciate some advice.

I am considering using guile inside an existing multi-threaded
(pthreads, solaris 2.6,7,8) application. I'm aware of many of the limitations
(at least as of October 2001, which is the latest message I've seen on
the issue) including using guile inside a single thread. So here's a
proposed sketch of the project. Any obvious faulty thinking?

We have a client-server architecture. Data enters the client, and is
passed to the server. At startup, the server loads an arbitrary number of
processing modules. When the server receives a data packet from the
client, it spawns a processing thread. This thread runs the data
through each of the processing modules in sequence. Many of these
threads (thousands, sometimes) exist simultaneously.

What I want to do is to write a processing module which uses Guile. 
The module will load its (scheme) processing commands at startup, and
munge data using this scheme code when called from a processing thread. 
As a bonus constraint, I'm not allowed to modify the server itself.

So far as I can tell, this means that the guile module will need to
spawn an interpreter thread at server startup time, and then when it
processes a data packet, send the data off to the interpreter thread
and wait for a response. Probably the guile call will be gh_eval_str(),
since I will be feeding it data and waiting for responses to pull back
into C.

Now, this is kind-of asking for a bottleneck right there, but I can
imagine using guile's threads to ease it somewhat if it becomes a
problem. So here are some questions:

 . The guile interpreter may not be fired up by the process's
   main thread, but some other one, and at some other time than 
   the end of main(). Is this a problem?

 . I don't understand the arguments to gh_enter(). The main 
   thread's argc and argv will not be available to 
   gh_enter(). If the `inner_main' of gh_enter() is not going
   to need data passed to it, can these contain dummy values?

 . Will I be able to use guile's threads inside a system such as
   the one described (that is, inside a non-main thread) ?

 . Are there other obvious-to-the-seasoned-guiler sorts of issues
   that I'd do better with if I knew of in advance?

Any thoughts on the situation are actively solicited.

Thanks a whole bunch,

Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup

reply via email to

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