[Top][All Lists]

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

[Guile-commits] GNU Guile branch, master, updated. release_1-9-2-101-g71

From: Neil Jerram
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-2-101-g71a5964
Date: Wed, 26 Aug 2009 22:36:36 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

The branch, master has been updated
       via  71a5964c110bea93ac926331547c25bdff67ce23 (commit)
      from  a66480374ed6dfc2d012c6df39c1382ba87ed9d0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 71a5964c110bea93ac926331547c25bdff67ce23
Author: Ken Raeburn <address@hidden>
Date:   Wed Aug 26 23:30:59 2009 +0100

    Don't leave and reenter guile mode if mutex is available
    On Aug 5, 2009, at 10:06, Ken Raeburn wrote:
    > (1) In scm_pthread_mutex_lock, we leave and re-enter guile mode so
    > that we don't block the thread while in guile mode.  But we could
    > use pthread_mutex_trylock first, and avoid the costs scm_leave_guile
    > seems to incur on the Mac.  If we can't acquire the lock, it should
    > return immediately, and then we can do the expensive, blocking
    > version.  A quick, hack version of this changed my run time for
    > A(3,8) from 17.5s to 14.5s, saving about 17%; sigaltstack and
    > sigprocmask are still in the picture, because they're called from
    > scm_catch_with_pre_unwind_handler.  I'll work up a nicer patch
    > later.
    Ah, we already had scm_i_pthread_mutex_trylock lying around; that made
    things easy.
    A second timing test with A(3,9) and this version of the patch (based
    on 1.9.1) shows the same improvement.
    * libguile/threads.c (scm_pthread_mutex_lock): Try the mutex before
      leaving and reentering guile mode.


Summary of changes:
 libguile/threads.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libguile/threads.c b/libguile/threads.c
index 1721e0b..e468f2f 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -1826,10 +1826,15 @@ scm_std_select (int nfds,
 scm_pthread_mutex_lock (scm_i_pthread_mutex_t *mutex)
-  scm_t_guile_ticket t = scm_leave_guile ();
-  int res = scm_i_pthread_mutex_lock (mutex);
-  scm_enter_guile (t);
-  return res;
+  if (scm_i_pthread_mutex_trylock (mutex) == 0)
+    return 0;
+  else
+    {
+      scm_t_guile_ticket t = scm_leave_guile ();
+      int res = scm_i_pthread_mutex_lock (mutex);
+      scm_enter_guile (t);
+      return res;
+    }
 static void

GNU Guile

reply via email to

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