From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rixed@happyleptic.org Newsgroups: gmane.lisp.guile.user Subject: Thread and guile environment Date: Mon, 5 Jul 2010 10:23:11 +0200 Message-ID: <20100705082310.GA9492@apc> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="UugvWAfsgieZRqgk" X-Trace: dough.gmane.org 1278318250 8965 80.91.229.12 (5 Jul 2010 08:24:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Jul 2010 08:24:10 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jul 05 10:24:08 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OVgyG-0004Th-3m for guile-user@m.gmane.org; Mon, 05 Jul 2010 10:24:08 +0200 Original-Received: from localhost ([127.0.0.1]:39031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVgyF-0001y0-Et for guile-user@m.gmane.org; Mon, 05 Jul 2010 04:24:07 -0400 Original-Received: from [140.186.70.92] (port=43761 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVgxx-0001xU-2M for guile-user@gnu.org; Mon, 05 Jul 2010 04:23:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OVgxv-000213-VW for guile-user@gnu.org; Mon, 05 Jul 2010 04:23:48 -0400 Original-Received: from smtp5-g21.free.fr ([212.27.42.5]:35233) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OVgxv-0001wf-Cu for guile-user@gnu.org; Mon, 05 Jul 2010 04:23:47 -0400 Original-Received: from apc.happyleptic.org (unknown [82.67.194.89]) by smtp5-g21.free.fr (Postfix) with ESMTP id E075FD48114 for ; Mon, 5 Jul 2010 10:23:19 +0200 (CEST) Original-Received: by apc.happyleptic.org (Postfix, from userid 1004) id 6454133877; Mon, 5 Jul 2010 10:23:11 +0200 (CEST) Content-Disposition: inline User-Agent: Mutt/1.5.12-2006-07-14 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7955 Archived-At: --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 ? --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bug.c" #include #include #include 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; } --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bug.scm" (use-modules (ice-9 format)) (define (hug x) (format #t "HUG ~a !\n" x)) --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Makefile CFLAGS += $(shell guile-config compile) LDLIBS += $(shell guile-config link) -lpthread all: bug --UugvWAfsgieZRqgk--