guile-user
[Top][All Lists]
Advanced

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

Re: Threads with foreign functions


From: Ola Leifler
Subject: Re: Threads with foreign functions
Date: Thu, 30 Oct 2003 14:23:53 +0100
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.5) Gecko/20031029

Clinton Ebadi wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 30 October 2003 01:37, Ola Leifler wrote:
[snip]

haven't found any useful informaton on it, at least not if you're using
SWIG. First, I tried to start Guile from a C-program in one C-thread
while the other C-thread printed some data repeatedly that came from
this global variable. Guile could not successfully change this parameter
so that the C-thread saw the change. See code snippet below. I thought
this was because Guile loaded a shared library in order to get access to
the C interface and thus loaded a *copy* of all the functions/variables
that were already accessible to the C program.

extern tortoise *t;
void inner_main(int argc, char *argv[]){
   pid_t pid;
   int exit_val;
   t = make_tortoise();
   switch(pid = fork()) {


When you fork a program, a copy of the address space is made so now the child has copies of all the variables in the main program. You need to use threads to do what you want to do. Pthreads should work with both Guile 1.6 and 1.7, but you must be careful only to access Guile from one thread at a time with 1.6 (with 1.7 it shouldn't matter as long as Guile is using the pthreads backend).


I just realized that and changed my program to using pthreads :)

Calling Guile from only one thread shouldn't be a problem I think.

Thanks a bunch!

/Ola

--
address@hidden Dept. of Computer and Information Science
Linkopings universitet
SE-581 83  LINKOPING - SWEDEN





reply via email to

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