Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread When a thread sleeps on a mutex or cv, have i...



details:   https://anonhg.NetBSD.org/src/rev/a4cce1996adf
branches:  trunk
changeset: 545811:a4cce1996adf
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Wed Apr 16 18:30:43 2003 +0000

description:
When a thread sleeps on a mutex or cv, have it put itself on the
front of the sleep queue rather than the back. This is more
cache-friendly behavior and within the (lack of) constraints on wakeup
ordering imposed on equal-priority threads.

diffstat:

 lib/libpthread/pthread_cond.c  |  8 ++++----
 lib/libpthread/pthread_mutex.c |  6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diffs (63 lines):

diff -r f4046a3a1d57 -r a4cce1996adf lib/libpthread/pthread_cond.c
--- a/lib/libpthread/pthread_cond.c     Wed Apr 16 17:38:43 2003 +0000
+++ b/lib/libpthread/pthread_cond.c     Wed Apr 16 18:30:43 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cond.c,v 1.8 2003/03/08 08:03:35 lukem Exp $   */
+/*     $NetBSD: pthread_cond.c,v 1.9 2003/04/16 18:30:44 nathanw Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cond.c,v 1.8 2003/03/08 08:03:35 lukem Exp $");
+__RCSID("$NetBSD: pthread_cond.c,v 1.9 2003/04/16 18:30:44 nathanw Exp $");
 
 #include <errno.h>
 #include <sys/time.h>
@@ -149,7 +149,7 @@
        self->pt_sleeplock = &cond->ptc_lock;
        pthread_spinunlock(self, &self->pt_statelock);
 
-       PTQ_INSERT_TAIL(&cond->ptc_waiters, self, pt_sleep);
+       PTQ_INSERT_HEAD(&cond->ptc_waiters, self, pt_sleep);
        pthread_mutex_unlock(mutex);
 
        pthread__block(self, &cond->ptc_lock);
@@ -229,7 +229,7 @@
        self->pt_sleeplock = &cond->ptc_lock;
        pthread_spinunlock(self, &self->pt_statelock);
 
-       PTQ_INSERT_TAIL(&cond->ptc_waiters, self, pt_sleep);
+       PTQ_INSERT_HEAD(&cond->ptc_waiters, self, pt_sleep);
        pthread_mutex_unlock(mutex);
 
        pthread__block(self, &cond->ptc_lock);
diff -r f4046a3a1d57 -r a4cce1996adf lib/libpthread/pthread_mutex.c
--- a/lib/libpthread/pthread_mutex.c    Wed Apr 16 17:38:43 2003 +0000
+++ b/lib/libpthread/pthread_mutex.c    Wed Apr 16 18:30:43 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_mutex.c,v 1.10 2003/03/08 08:03:35 lukem Exp $ */
+/*     $NetBSD: pthread_mutex.c,v 1.11 2003/04/16 18:30:43 nathanw Exp $       */
 
 /*-
  * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_mutex.c,v 1.10 2003/03/08 08:03:35 lukem Exp $");
+__RCSID("$NetBSD: pthread_mutex.c,v 1.11 2003/04/16 18:30:43 nathanw Exp $");
 
 #include <errno.h>
 #include <limits.h>
@@ -244,7 +244,7 @@
                                }
                        }
 
-                       PTQ_INSERT_TAIL(&mutex->ptm_blocked, self, pt_sleep);
+                       PTQ_INSERT_HEAD(&mutex->ptm_blocked, self, pt_sleep);
                        /*
                         * Locking a mutex is not a cancellation
                         * point, so we don't need to do the



Home | Main Index | Thread Index | Old Index