guile-user
[Top][All Lists]
Advanced

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

Re: Coop threads reliability !?


From: Mikael Djurfeldt
Subject: Re: Coop threads reliability !?
Date: 22 Oct 2001 17:16:53 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Andrea Pippa <address@hidden> writes:

> My problem is that coop threads seem to be somewhat
> unaffidable... !? is that a known issue in guile or is that
> something new ?

This is an old bug (existent already in 1.3.4) which wasn't apparent
in earlier versions of Linux pthreads.

This has been fixed in more recent versions of Guile (and in the
coming 1.6 release).

Here's a patch:

Index: guile/guile-core/libguile/ChangeLog
diff -c guile/guile-core/libguile/ChangeLog:1.1522 
guile/guile-core/libguile/ChangeLog:1.1524
*** guile/guile-core/libguile/ChangeLog:1.1522  Fri Oct  5 16:18:30 2001
--- guile/guile-core/libguile/ChangeLog Sat Oct  6 16:01:36 2001
***************
*** 1,3 ****
--- 1,13 ----
+ 2001-10-06  Mikael Djurfeldt  <address@hidden>
+ 
+       These changes fixes a race condition in the Guile coop - pthread
+       compatibility code.
+       
+       * coop.c (mother_awake_p): New variable.
+       (coop_create): Set mother_awake_p before creating or signalling
+       mother; wait until mother is going to sleep before returning.
+       (mother): Reset mother_awake_p before going to sleep.
+ 
  2001-10-05  Dirk Herrmann  <address@hidden>
  
        * options.c (protected_objects, scm_init_options):  The content of
Index: guile/guile-core/libguile/coop.c
diff -c guile/guile-core/libguile/coop.c:1.27 
guile/guile-core/libguile/coop.c:1.28
*** guile/guile-core/libguile/coop.c:1.27       Fri Mar  9 22:09:07 2001
--- guile/guile-core/libguile/coop.c    Sat Oct  6 12:30:20 2001
***************
*** 40,46 ****
   * If you do not wish that, delete this exception notice.  */
  
  
! /* $Id: coop.c,v 1.27 2001/03/10 03:09:07 mdj Exp $ */
  
  /* Cooperative thread library, based on QuickThreads */
  
--- 40,46 ----
   * If you do not wish that, delete this exception notice.  */
  
  
! /* $Id: coop.c,v 1.28 2001/10/06 16:30:20 mdj Exp $ */
  
  /* Cooperative thread library, based on QuickThreads */
  
***************
*** 171,176 ****
--- 171,177 ----
  static pthread_cond_t coop_cond_create;
  static pthread_mutex_t coop_mutex_create;
  static pthread_t coop_mother;
+ static int mother_awake_p = 0;
  static coop_t *coop_child;
  #endif
  
***************
*** 584,589 ****
--- 585,591 ----
                      NULL,
                      dummy_start,
                      coop_child);
+       mother_awake_p = 0;
        do
        res = pthread_cond_wait (&coop_cond_create, &coop_mutex_create);
        while (res == EINTR);
***************
*** 618,623 ****
--- 620,626 ----
        t->n_keys = 0;
  #ifdef GUILE_PTHREAD_COMPAT
        coop_child = t;
+       mother_awake_p = 1;
        if (coop_quitting_p < 0)
        {
          coop_quitting_p = 0;
***************
*** 635,641 ****
         * condition variable because they are not safe against
         * pre-emptive switching.
         */
!       while (coop_child)
        usleep (0);
  #else
        t->sto = malloc (COOP_STKSIZE);
--- 638,644 ----
         * condition variable because they are not safe against
         * pre-emptive switching.
         */
!       while (coop_child || mother_awake_p)
        usleep (0);
  #else
        t->sto = malloc (COOP_STKSIZE);



reply via email to

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