Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread Add charles' mlock fixes, protected with PTHR...



details:   https://anonhg.NetBSD.org/src/rev/c0d54c29e2e1
branches:  trunk
changeset: 573624:c0d54c29e2e1
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Feb 03 17:30:33 2005 +0000

description:
Add charles' mlock fixes, protected with PTHREAD_MLOCK_KLUDGE and enabled
by default, until we come up with a real fix.

diffstat:

 lib/libpthread/Makefile  |   4 ++--
 lib/libpthread/pthread.c |  20 ++++++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diffs (88 lines):

diff -r ac1650c9428b -r c0d54c29e2e1 lib/libpthread/Makefile
--- a/lib/libpthread/Makefile   Thu Feb 03 16:31:32 2005 +0000
+++ b/lib/libpthread/Makefile   Thu Feb 03 17:30:33 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.29 2004/12/14 01:47:13 yamt Exp $
+#      $NetBSD: Makefile,v 1.30 2005/02/03 17:30:33 christos Exp $
 #
 
 WARNS= 2
@@ -26,7 +26,7 @@
 .PATH: ${ARCHDIR}
 
 CPPFLAGS+=     -I${ARCHDIR} -I${.CURDIR} -I${.OBJDIR} -D_LIBC
-CPPFLAGS+=     -D__LIBPTHREAD_SOURCE__
+CPPFLAGS+=     -D__LIBPTHREAD_SOURCE__ -DPTHREAD_MLOCK_KLUDGE
 
 DPSRCS+=       assym.h
 CLEANFILES+=   assym.h
diff -r ac1650c9428b -r c0d54c29e2e1 lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c  Thu Feb 03 16:31:32 2005 +0000
+++ b/lib/libpthread/pthread.c  Thu Feb 03 17:30:33 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread.c,v 1.37 2005/01/06 17:38:29 mycroft Exp $     */
+/*     $NetBSD: pthread.c,v 1.38 2005/02/03 17:30:33 christos Exp $    */
 
 /*-
  * Copyright (c) 2001,2002,2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.37 2005/01/06 17:38:29 mycroft Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.38 2005/02/03 17:30:33 christos Exp $");
 
 #include <err.h>
 #include <errno.h>
@@ -51,6 +51,9 @@
 #include <unistd.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
+#ifdef PTHREAD_MLOCK_KLUDGE
+#include <sys/mman.h>
+#endif
 
 #include <sched.h>
 #include "pthread.h"
@@ -134,6 +137,9 @@
        int i, mib[2], ncpu;
        size_t len;
        extern int __isthreaded;
+#ifdef PTHREAD_MLOCK_KLUDGE
+       int ret;
+#endif
 
        mib[0] = CTL_HW;
        mib[1] = HW_NCPU; 
@@ -164,6 +170,10 @@
        pthread_attr_init(&pthread_default_attr);
        PTQ_INIT(&pthread__allqueue);
        PTQ_INIT(&pthread__deadqueue);
+#ifdef PTHREAD_MLOCK_KLUDGE
+       ret = mlock(&pthread__deadqueue, sizeof(pthread__deadqueue));
+       pthread__assert(ret == 0);
+#endif
        PTQ_INIT(&pthread__runqueue);
        PTQ_INIT(&pthread__idlequeue);
        for (i = 0; i < pthread__maxconcurrency; i++)
@@ -317,7 +327,9 @@
        pthread_attr_t nattr;
        struct pthread_attr_private *p;
        char *name;
+#ifdef PTHREAD_MLOCK_KLUDGE
        int ret;
+#endif
 
        PTHREADD_ADD(PTHREADD_CREATE);
 
@@ -360,6 +372,10 @@
                                free(name);
                        return ret;
                }
+#ifdef PTHREAD_MLOCK_KLUDGE
+               ret = mlock(newthread, sizeof(struct __pthread_st));
+               pthread__assert(ret == 0);
+#endif
        }
 
        /* 2. Set up state. */



Home | Main Index | Thread Index | Old Index