[Top][All Lists]

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

Re: Thread local storage

From: Ken Raeburn
Subject: Re: Thread local storage
Date: Tue, 6 Oct 2009 13:44:44 -0400

On Oct 4, 2009, at 10:03, Ludovic Courtès wrote:
I looked again at how/whether we could improve thread-local storage
access, using compiler support (the ‘__thread’ storage class).

For the most part I think the wip-tls changes look good. In the non- __thread case, though, you've eliminated the pthread_key_create call, making it not work on my Mac. (In addition to the still-present i18n.c compilation problem.) Assuming that __thread variables are by default initialized to 0 (or NULL or whatever we specify), we also don't need anything in init_thread_key when we have __thread support. I suggest something like the patch below. I haven't tried it on a system *with* the __thread support though.


--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -538,11 +538,13 @@ on_thread_exit (void *v)

static scm_i_pthread_once_t init_thread_key_once = SCM_I_PTHREAD_ONCE_INIT;

 static void
 init_thread_key (void)
+  scm_i_pthread_key_create (&scm_i_thread_key, NULL);

 /* Perform any initializations necessary to bring the current thread
    into guile mode, initializing Guile itself, if necessary.
@@ -561,7 +563,9 @@ scm_i_init_thread_for_guile (SCM_STACKITEM *base, SCM parent)
   scm_i_thread *t;

   scm_i_pthread_once (&init_thread_key_once, init_thread_key);

   if (t == NULL)

reply via email to

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