From: rixed@happyleptic.org
To: guile-user@gnu.org
Subject: Thread and guile environment
Date: Mon, 5 Jul 2010 10:23:11 +0200 [thread overview]
Message-ID: <20100705082310.GA9492@apc> (raw)
[-- Attachment #1: Type: text/plain, Size: 316 bytes --]
Suppose I have a multithreaded C program. Isn't the guile environment supposed
to be shared amongst all threads ? That's what I understood from reading the
docs anyway.
Yet this simple exemple shows the opposite (see the 3 attached files).
So am I supposed to source my global scheme definitions in all threads ?
[-- Attachment #2: bug.c --]
[-- Type: text/plain, Size: 604 bytes --]
#include <unistd.h>
#include <pthread.h>
#include <libguile.h>
static void *load_file_with_guile(void *filename)
{
scm_c_primitive_load((char *)filename);
return NULL;
}
static void *hug_me(void *str)
{
scm_c_eval_string(str);
}
static void *thread_hugme(void *dummy)
{
//scm_with_guile(load_file_with_guile, "bug.scm");
scm_with_guile(hug_me, "(hug 2)");
return NULL;
}
int main(void) {
scm_with_guile(load_file_with_guile, "bug.scm");
scm_with_guile(hug_me, "(hug 1)");
pthread_t thread;
pthread_create(&thread, NULL, thread_hugme, NULL);
pthread_join(thread, NULL);
return 0;
}
[-- Attachment #3: bug.scm --]
[-- Type: text/plain, Size: 73 bytes --]
(use-modules (ice-9 format))
(define (hug x) (format #t "HUG ~a !\n" x))
[-- Attachment #4: Makefile --]
[-- Type: text/plain, Size: 97 bytes --]
CFLAGS += $(shell guile-config compile)
LDLIBS += $(shell guile-config link) -lpthread
all: bug
next reply other threads:[~2010-07-05 8:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-05 8:23 rixed [this message]
2010-07-05 19:52 ` Thread and guile environment Neil Jerram
2010-07-06 11:22 ` Cedric Cellier
2010-07-07 11:02 ` Cedric Cellier
2010-07-08 19:48 ` Andy Wingo
2010-07-09 15:54 ` Cedric Cellier
2010-07-09 19:10 ` Andy Wingo
2010-07-09 20:23 ` Neil Jerram
2010-07-10 8:22 ` Andy Wingo
2010-07-12 20:24 ` Linas Vepstas
2010-07-17 12:24 ` Andy Wingo
2010-07-12 8:09 ` Cedric Cellier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100705082310.GA9492@apc \
--to=rixed@happyleptic.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).