Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Apr 2003 19:24:56 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 29372 for review
Message-ID:  <200304220224.h3M2OuFl047689@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=29372

Change 29372 by marcel@marcel_pluto1 on 2003/04/21 19:24:55

	IFia64

Affected files ...

.. //depot/projects/ia64_epc/etc/rc.d/dhclient#3 integrate
.. //depot/projects/ia64_epc/lib/libalias/Makefile#2 integrate
.. //depot/projects/ia64_epc/lib/libatm/atm_addr.c#3 integrate
.. //depot/projects/ia64_epc/lib/libc/gen/getpwent.c#5 integrate
.. //depot/projects/ia64_epc/lib/libc/include/nss_tls.h#2 integrate
.. //depot/projects/ia64_epc/lib/libdisk/Makefile#2 integrate
.. //depot/projects/ia64_epc/lib/libdisk/write_sparc64_disk.c#2 integrate
.. //depot/projects/ia64_epc/lib/libpthread/Makefile#3 integrate
.. //depot/projects/ia64_epc/lib/libpthread/arch/i386/i386/thr_switch.S#3 integrate
.. //depot/projects/ia64_epc/lib/libpthread/thread/thr_cond.c#3 integrate
.. //depot/projects/ia64_epc/lib/libpthread/thread/thr_create.c#3 integrate
.. //depot/projects/ia64_epc/lib/libpthread/thread/thr_kern.c#4 integrate
.. //depot/projects/ia64_epc/lib/libpthread/thread/thr_private.h#4 integrate
.. //depot/projects/ia64_epc/lib/libpthread/thread/thr_setschedparam.c#3 integrate
.. //depot/projects/ia64_epc/lib/libpthread/thread/thr_suspend_np.c#3 integrate
.. //depot/projects/ia64_epc/lib/libthr/arch/ia64/Makefile.inc#2 integrate
.. //depot/projects/ia64_epc/lib/libthr/arch/ia64/ia64/_curthread.c#2 integrate
.. //depot/projects/ia64_epc/release/alpha/drivers.conf#2 integrate
.. //depot/projects/ia64_epc/release/alpha/fixit_crunch.conf#2 integrate
.. //depot/projects/ia64_epc/release/i386/drivers.conf#5 integrate
.. //depot/projects/ia64_epc/release/i386/fixit_crunch.conf#2 integrate
.. //depot/projects/ia64_epc/release/pc98/drivers.conf#3 integrate
.. //depot/projects/ia64_epc/release/pc98/fixit-small_crunch.conf#2 integrate
.. //depot/projects/ia64_epc/release/pc98/fixit_crunch.conf#2 integrate
.. //depot/projects/ia64_epc/sbin/devd/devd.8#4 integrate
.. //depot/projects/ia64_epc/sbin/devd/devd.cc#2 integrate
.. //depot/projects/ia64_epc/sbin/newfs/newfs.8#3 integrate
.. //depot/projects/ia64_epc/sbin/newfs/newfs.c#3 integrate
.. //depot/projects/ia64_epc/sbin/sunlabel/Makefile#3 integrate
.. //depot/projects/ia64_epc/sbin/sunlabel/runtest.sh#1 branch
.. //depot/projects/ia64_epc/sbin/sunlabel/sunlabel.c#4 integrate
.. //depot/projects/ia64_epc/share/dict/freebsd#2 integrate
.. //depot/projects/ia64_epc/share/man/man4/Makefile#7 integrate
.. //depot/projects/ia64_epc/share/man/man4/asr.4#2 integrate
.. //depot/projects/ia64_epc/share/man/man4/axe.4#1 branch
.. //depot/projects/ia64_epc/share/man/man4/isp.4#2 integrate
.. //depot/projects/ia64_epc/share/man/man4/man4.i386/Makefile#6 integrate
.. //depot/projects/ia64_epc/share/man/man4/man4.i386/asr.4#2 delete
.. //depot/projects/ia64_epc/share/man/man4/mlx.4#2 integrate
.. //depot/projects/ia64_epc/share/man/man4/smp.4#2 integrate
.. //depot/projects/ia64_epc/share/man/man4/sym.4#2 integrate
.. //depot/projects/ia64_epc/share/man/man4/syscons.4#2 integrate
.. //depot/projects/ia64_epc/share/man/man9/Makefile#3 integrate
.. //depot/projects/ia64_epc/share/man/man9/device_get_name.9#1 branch
.. //depot/projects/ia64_epc/share/man/man9/device_get_parent.9#1 branch
.. //depot/projects/ia64_epc/share/man/man9/device_get_state.9#2 integrate
.. //depot/projects/ia64_epc/sys/alpha/alpha/dec_2100_a500.c#2 integrate
.. //depot/projects/ia64_epc/sys/alpha/conf/GENERIC#4 integrate
.. //depot/projects/ia64_epc/sys/conf/files#11 integrate
.. //depot/projects/ia64_epc/sys/conf/files.sparc64#6 integrate
.. //depot/projects/ia64_epc/sys/contrib/ipfilter/netinet/ip_state.c#3 integrate
.. //depot/projects/ia64_epc/sys/crypto/blowfish/arch/i386/bf_enc_586.S#2 integrate
.. //depot/projects/ia64_epc/sys/crypto/des/arch/i386/des_enc.S#2 integrate
.. //depot/projects/ia64_epc/sys/dev/awi/am79c930.c#2 integrate
.. //depot/projects/ia64_epc/sys/dev/firewire/fwdev.c#5 integrate
.. //depot/projects/ia64_epc/sys/dev/hea/eni_transmit.c#2 integrate
.. //depot/projects/ia64_epc/sys/dev/sound/pci/emu10k1.c#5 integrate
.. //depot/projects/ia64_epc/sys/dev/sound/pcm/ac97.c#6 integrate
.. //depot/projects/ia64_epc/sys/dev/sound/pcm/buffer.c#3 integrate
.. //depot/projects/ia64_epc/sys/dev/sound/pcm/feeder_fmt.c#4 integrate
.. //depot/projects/ia64_epc/sys/dev/sound/pcm/feeder_rate.c#4 integrate
.. //depot/projects/ia64_epc/sys/dev/tx/if_tx.c#5 integrate
.. //depot/projects/ia64_epc/sys/dev/tx/if_txvar.h#3 integrate
.. //depot/projects/ia64_epc/sys/dev/usb/if_axe.c#1 branch
.. //depot/projects/ia64_epc/sys/dev/usb/if_axereg.h#1 branch
.. //depot/projects/ia64_epc/sys/dev/usb/usbdevs#7 integrate
.. //depot/projects/ia64_epc/sys/dev/usb/usbdevs.h#7 integrate
.. //depot/projects/ia64_epc/sys/dev/usb/usbdevs_data.h#7 integrate
.. //depot/projects/ia64_epc/sys/geom/geom_sunlabel.c#5 integrate
.. //depot/projects/ia64_epc/sys/geom/geom_sunlabel_enc.c#1 branch
.. //depot/projects/ia64_epc/sys/gnu/dev/sound/pci/emu10k1-ac97.h#1 branch
.. //depot/projects/ia64_epc/sys/i386/conf/GENERIC#4 integrate
.. //depot/projects/ia64_epc/sys/i386/i386/vm_machdep.c#5 integrate
.. //depot/projects/ia64_epc/sys/i386/svr4/svr4_locore.s#2 integrate
.. //depot/projects/ia64_epc/sys/ia64/conf/GENERIC#6 integrate
.. //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#7 integrate
.. //depot/projects/ia64_epc/sys/ia64/include/pmap.h#5 integrate
.. //depot/projects/ia64_epc/sys/kern/kern_exit.c#7 integrate
.. //depot/projects/ia64_epc/sys/kern/kern_thread.c#12 integrate
.. //depot/projects/ia64_epc/sys/kern/subr_bus.c#5 integrate
.. //depot/projects/ia64_epc/sys/modules/Makefile#9 integrate
.. //depot/projects/ia64_epc/sys/modules/axe/Makefile#1 branch
.. //depot/projects/ia64_epc/sys/modules/netgraph/Makefile#2 integrate
.. //depot/projects/ia64_epc/sys/netgraph/ng_fec.c#3 integrate
.. //depot/projects/ia64_epc/sys/netinet/tcp_input.c#7 integrate
.. //depot/projects/ia64_epc/sys/netinet6/icmp6.c#4 integrate
.. //depot/projects/ia64_epc/sys/pc98/conf/GENERIC#4 integrate
.. //depot/projects/ia64_epc/sys/pci/if_dc.c#7 integrate
.. //depot/projects/ia64_epc/sys/pci/if_pcn.c#6 integrate
.. //depot/projects/ia64_epc/sys/pci/if_rl.c#8 integrate
.. //depot/projects/ia64_epc/sys/pci/if_sf.c#6 integrate
.. //depot/projects/ia64_epc/sys/pci/if_sis.c#6 integrate
.. //depot/projects/ia64_epc/sys/pci/if_sk.c#6 integrate
.. //depot/projects/ia64_epc/sys/pci/if_ste.c#6 integrate
.. //depot/projects/ia64_epc/sys/pci/if_ti.c#7 integrate
.. //depot/projects/ia64_epc/sys/pci/if_tl.c#6 integrate
.. //depot/projects/ia64_epc/sys/pci/if_vr.c#7 integrate
.. //depot/projects/ia64_epc/sys/pci/if_wb.c#6 integrate
.. //depot/projects/ia64_epc/sys/pci/if_xl.c#11 integrate
.. //depot/projects/ia64_epc/sys/powerpc/conf/GENERIC#4 integrate
.. //depot/projects/ia64_epc/sys/sparc64/conf/GENERIC#6 integrate
.. //depot/projects/ia64_epc/sys/sys/bus.h#3 integrate
.. //depot/projects/ia64_epc/sys/sys/kse.h#4 integrate
.. //depot/projects/ia64_epc/sys/sys/proc.h#10 integrate
.. //depot/projects/ia64_epc/sys/sys/resourcevar.h#3 integrate
.. //depot/projects/ia64_epc/sys/sys/sun_disklabel.h#2 integrate
.. //depot/projects/ia64_epc/sys/vm/vm_fault.c#6 integrate
.. //depot/projects/ia64_epc/sys/vm/vm_map.c#8 integrate
.. //depot/projects/ia64_epc/sys/vm/vm_object.c#9 integrate
.. //depot/projects/ia64_epc/sys/vm/vm_pageout.c#5 integrate
.. //depot/projects/ia64_epc/usr.sbin/config/config.8#3 integrate
.. //depot/projects/ia64_epc/usr.sbin/jail/jail.c#5 integrate
.. //depot/projects/ia64_epc/usr.sbin/sysinstall/devices.c#3 integrate
.. //depot/projects/ia64_epc/usr.sbin/sysinstall/help/partition.hlp#2 integrate
.. //depot/projects/ia64_epc/usr.sbin/sysinstall/install.c#3 integrate
.. //depot/projects/ia64_epc/usr.sbin/sysinstall/label.c#2 integrate
.. //depot/projects/ia64_epc/usr.sbin/sysinstall/sysinstall.h#4 integrate

Differences ...

==== //depot/projects/ia64_epc/etc/rc.d/dhclient#3 (text+ko) ====

@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $
-# $FreeBSD: src/etc/rc.d/dhclient,v 1.3 2003/04/18 17:53:02 mtm Exp $
+# $FreeBSD: src/etc/rc.d/dhclient,v 1.4 2003/04/20 19:14:16 mtm Exp $
 #
 
 # PROVIDE: dhclient
@@ -36,6 +36,11 @@
 	if [ -z "$dhcp_list" ]; then
 		return 1
 	fi
+
+	for ifn in ${dhcp_list}; do
+		ifscript_up ${ifn}
+	done
+
 	rc_flags="${rc_flags} ${dhcp_flags} ${dhcp_list}"
 	return 0
 }

==== //depot/projects/ia64_epc/lib/libalias/Makefile#2 (text+ko) ====

@@ -1,12 +1,11 @@
-# $FreeBSD: src/lib/libalias/Makefile,v 1.19 2002/09/28 00:25:28 peter Exp $
+# $FreeBSD: src/lib/libalias/Makefile,v 1.20 2003/04/20 18:38:59 obrien Exp $
 
-LIB=		alias
+LIB=	alias
 SHLIB_MAJOR=	4
-CFLAGS+=	-Wall -Wmissing-prototypes
-SRCS=		alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \
-		alias_nbt.c alias_pptp.c alias_proxy.c alias_smedia.c \
-		alias_util.c
-INCS=		alias.h
-MAN=		libalias.3
+MAN=	libalias.3
+SRCS=	alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \
+	alias_nbt.c alias_pptp.c alias_proxy.c alias_smedia.c \
+	alias_util.c
+INCS=	alias.h
 
 .include <bsd.lib.mk>

==== //depot/projects/ia64_epc/lib/libatm/atm_addr.c#3 (text+ko) ====

@@ -24,13 +24,13 @@
  * notice must be reproduced on all copies.
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libatm/atm_addr.c,v 1.9 2003/03/25 04:29:26 mdodd Exp $");
 #ifndef lint
 #if 0	/* original (broken) import id */
 static char *RCSid = "@(#) $Id: atm_addr.c,v 1.1 1998/07/09 21:45:18 johnc Exp $";
 #endif
 #endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libatm/atm_addr.c,v 1.10 2003/04/20 18:41:16 obrien Exp $");
 
 /*
  * User Space Library Functions

==== //depot/projects/ia64_epc/lib/libc/gen/getpwent.c#5 (text+ko) ====

@@ -31,7 +31,7 @@
  *
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/getpwent.c,v 1.76 2003/04/18 22:07:30 nectar Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/gen/getpwent.c,v 1.77 2003/04/21 13:57:58 nectar Exp $");
 
 #include "namespace.h"
 #include <sys/param.h>
@@ -941,13 +941,15 @@
 	int	rv, order;
 
 	*master = 0;
-	if (snprintf(buffer, bufsize, "master.passwd.by%s",
-	    (how == nss_lt_id) ? "uid" : "name") >= bufsize)
-		return (NS_UNAVAIL);
-	rv = yp_order(domain, buffer, &order);
-	if (rv == 0) {
-		*master = 1;
-		return (NS_SUCCESS);
+	if (geteuid() == 0) {
+		if (snprintf(buffer, bufsize, "master.passwd.by%s",
+		    (how == nss_lt_id) ? "uid" : "name") >= bufsize)
+			return (NS_UNAVAIL);
+		rv = yp_order(domain, buffer, &order);
+		if (rv == 0) {
+			*master = 1;
+			return (NS_SUCCESS);
+		}
 	}
 	if (snprintf(buffer, bufsize, "passwd.by%s",
 	    (how == nss_lt_id) ? "uid" : "name") >= bufsize)

==== //depot/projects/ia64_epc/lib/libc/include/nss_tls.h#2 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libc/include/nss_tls.h,v 1.1 2003/04/17 14:14:22 nectar Exp $
+ * $FreeBSD: src/lib/libc/include/nss_tls.h,v 1.2 2003/04/21 15:44:25 nectar Exp $
  *
  * Macros which generate thread local storage handling code in NSS modules.
  */
@@ -64,7 +64,7 @@
 	*p = _pthread_getspecific(name##_state_key);		\
 	if (*p != NULL)						\
 		return (0);					\
-	*p = calloc(1, sizeof(*p));				\
+	*p = calloc(1, sizeof(**p));				\
 	if (*p == NULL)						\
 		return (ENOMEM);				\
 	rv = _pthread_setspecific(name##_state_key, *p);	\

==== //depot/projects/ia64_epc/lib/libdisk/Makefile#2 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libdisk/Makefile,v 1.37 2002/10/31 05:43:49 nyan Exp $
+# $FreeBSD: src/lib/libdisk/Makefile,v 1.38 2003/04/21 20:36:44 phk Exp $
 
 LIB=	disk
 SRCS=	blocks.c chunk.c disk.c change.c \
@@ -7,6 +7,8 @@
 
 WARNS=	2
 
+CFLAGS+=	-I${.CURDIR}/../../sys/geom
+
 .if ${MACHINE} == "pc98"
 CFLAGS+=	-DPC98
 .endif

==== //depot/projects/ia64_epc/lib/libdisk/write_sparc64_disk.c#2 (text+ko) ====

@@ -8,7 +8,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libdisk/write_sparc64_disk.c,v 1.6 2002/11/15 13:24:29 nyan Exp $");
+__FBSDID("$FreeBSD: src/lib/libdisk/write_sparc64_disk.c,v 1.7 2003/04/21 20:36:44 phk Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -24,6 +24,8 @@
 #include <errno.h>
 #include "libdisk.h"
 
+#include "geom_sunlabel_enc.c"
+
 int
 Write_Disk(const struct disk *d1)
 {
@@ -34,6 +36,7 @@
 	u_long secpercyl;
 	u_short *sp1, *sp2, cksum;
 	char device[64];
+	u_char buf[SUN_SIZE];
 	int fd;
 
 	strcpy(device, _PATH_DEV);
@@ -74,9 +77,11 @@
 		p = c1->name;
 		p += strlen(p);
 		p--;
-		if (*p < 'a' || *p > 'h')
+		if (*p < 'a')
 			continue;
 		i = *p - 'a';
+		if (i >= SUN_NPART)
+			continue;
 		sl->sl_part[i].sdkp_cyloffset = c1->offset / secpercyl;
 		sl->sl_part[i].sdkp_nsectors = c1->size;
 		for (i = 1; i < 16; i++) {
@@ -90,17 +95,12 @@
 	 * seems to indicate that this covers the "obviously" visible part
 	 * of the disk, ie: sl->sl_ncylinders.
 	 */
-	sl->sl_part[2].sdkp_cyloffset = 0;
-	sl->sl_part[2].sdkp_nsectors = sl->sl_ncylinders * secpercyl;
+	sl->sl_part[SUN_RAWPART].sdkp_cyloffset = 0;
+	sl->sl_part[SUN_RAWPART].sdkp_nsectors = sl->sl_ncylinders * secpercyl;
 
-	sp1 = (u_short *)sl;
-	sp2 = (u_short *)(sl + 1);
-	sl->sl_cksum = cksum = 0;
-	while (sp1 < sp2)
-		cksum ^= *sp1++;
-	sl->sl_cksum = cksum;
-
-	write_block(fd, 0, sl, sizeof *sl);
+	memset(buf, 0, sizeof buf);
+	sunlabel_enc(buf, &sl);
+	write_block(fd, 0, buf, sizeof buf);
 
 	close(fd);
 	return 0;

==== //depot/projects/ia64_epc/lib/libpthread/Makefile#3 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libpthread/Makefile,v 1.38 2003/04/18 07:09:42 deischen Exp $
+# $FreeBSD: src/lib/libpthread/Makefile,v 1.39 2003/04/21 04:02:56 deischen Exp $
 #
 # All library objects contain FreeBSD revision strings by default; they may be
 # excluded as a space-saving measure.  To produce a library that does
@@ -17,7 +17,12 @@
 
 # Uncomment this if you want libpthread to contain debug information for
 # thread locking.
-#CFLAGS+=-D_LOCK_DEBUG -g
+CFLAGS+=-D_LOCK_DEBUG
+#CFLAGS+= -g
+
+.if ${MACHINE_ARCH} == "i386"
+CFLAGS+=-DGS_HACK
+.endif
 
 # enable extra internal consistancy checks
 CFLAGS+=-D_PTHREADS_INVARIANTS -Wall

==== //depot/projects/ia64_epc/lib/libpthread/arch/i386/i386/thr_switch.S#3 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <machine/asm.h>
-__FBSDID("$FreeBSD: src/lib/libpthread/arch/i386/i386/thr_switch.S,v 1.4 2003/04/18 05:00:52 deischen Exp $");
+__FBSDID("$FreeBSD: src/lib/libpthread/arch/i386/i386/thr_switch.S,v 1.5 2003/04/21 03:59:07 deischen Exp $");
 
 /*
  * Where do we define these?
@@ -106,6 +106,6 @@
 	movl	%ebx,(%ecx)
 	popl	%ecx			/* %ecx off stack */
 	popl	%ebx			/* %ebx off stack */
-	popf				/* flags off stack */
+	popfl				/* flags off stack */
 5:	ret				/* %eip off stack */
 

==== //depot/projects/ia64_epc/lib/libpthread/thread/thr_cond.c#3 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_cond.c,v 1.35 2003/04/18 05:04:15 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_cond.c,v 1.36 2003/04/21 04:02:56 deischen Exp $
  */
 #include <stdlib.h>
 #include <errno.h>
@@ -102,7 +102,7 @@
 			    malloc(sizeof(struct pthread_cond))) == NULL) {
 				rval = ENOMEM;
 			} else if (_lock_init(&pcond->c_lock, LCK_ADAPTIVE,
-			    _kse_lock_wait, _kse_lock_wakeup) != 0) {
+			    _thr_lock_wait, _thr_lock_wakeup) != 0) {
 				free(pcond);
 				rval = ENOMEM;
 			} else {

==== //depot/projects/ia64_epc/lib/libpthread/thread/thr_create.c#3 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_create.c,v 1.39 2003/04/18 07:09:43 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_create.c,v 1.40 2003/04/21 04:02:56 deischen Exp $
  */
 #include <errno.h>
 #include <stdlib.h>
@@ -103,11 +103,20 @@
 	if (_thr_initial == NULL)
 		_libpthread_init(NULL);
 
-	crit = _kse_critical_enter();
+	/*
+	 * Turn on threaded mode, if failed, it is unnecessary to
+	 * do further work.
+	 */
+	if (_kse_isthreaded() == 0 && _kse_setthreaded(1)) {
+		return (EAGAIN);
+	}
 	curthread = _get_curthread();
-	curkse = curthread->kse;
 
-	/* Allocate memory for the thread structure: */
+	/*
+	 * Allocate memory for the thread structure.
+	 * Some functions use malloc, so don't put it
+	 * in a critical region.
+	 */
 	if ((new_thread = _thr_alloc(curthread)) == NULL) {
 		/* Insufficient memory to create a thread: */
 		ret = EAGAIN;
@@ -135,9 +144,13 @@
 			if (kse != NULL)
 				_kse_free(curthread, kse);
 			if ((new_thread->attr.flags & THR_STACK_USER) == 0) {
+				crit = _kse_critical_enter();
+				curkse = _get_curkse();
 				KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock);
+				/* Stack routines don't use malloc/free. */
 				_thr_stack_free(&new_thread->attr);
 				KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
+				_kse_critical_leave(crit);
 			}
 			_thr_free(curthread, new_thread);
 		}
@@ -169,8 +182,13 @@
 			/* Initialize the signal frame: */
 			new_thread->curframe = NULL;
 
-			/* Initialize the machine context: */
+			/*
+			 * Initialize the machine context.
+			 * Enter a critical region to get consistent context.
+			 */
+			crit = _kse_critical_enter();
 			THR_GETCONTEXT(&new_thread->tmbx.tm_context);
+			_kse_critical_leave(crit);
 			new_thread->tmbx.tm_udata = new_thread;
 			new_thread->tmbx.tm_context.uc_sigmask =
 			    new_thread->sigmask;
@@ -178,17 +196,20 @@
 			    new_thread->attr.stacksize_attr;
 			new_thread->tmbx.tm_context.uc_stack.ss_sp =
 			    new_thread->attr.stackaddr_attr;
-
 			makecontext(&new_thread->tmbx.tm_context,
 			    (void (*)(void))thread_start, 4, new_thread,
 			    start_routine, arg);
-
 			/*
 			 * Check if this thread is to inherit the scheduling
 			 * attributes from its parent:
 			 */
 			if ((new_thread->attr.flags & PTHREAD_INHERIT_SCHED) != 0) {
-				/* Copy the scheduling attributes: */
+				/*
+				 * Copy the scheduling attributes.
+				 * Lock the scheduling lock to get consistent
+				 * scheduling parameters.
+				 */
+				THR_SCHED_LOCK(curthread, curthread);
 				new_thread->base_priority =
 				    curthread->base_priority &
 				    ~THR_SIGNAL_PRIORITY;
@@ -197,6 +218,7 @@
 				    ~THR_SIGNAL_PRIORITY;
 				new_thread->attr.sched_policy =
 				    curthread->attr.sched_policy;
+				THR_SCHED_UNLOCK(curthread, curthread);
 			} else {
 				/*
 				 * Use just the thread priority, leaving the
@@ -212,7 +234,11 @@
 			/* Initialize the mutex queue: */
 			TAILQ_INIT(&new_thread->mutexq);
 
-			/* Initialize thread locking. */
+			/*
+			 * Initialize thread locking.
+			 * Lock initializing needs malloc, so don't
+			 * enter critical region before doing this!
+			 */
 			if (_lock_init(&new_thread->lock, LCK_ADAPTIVE,
 			    _thr_lock_wait, _thr_lock_wakeup) != 0)
 				PANIC("Cannot initialize thread lock");
@@ -245,23 +271,24 @@
 			}
 			else {
 				kse->k_curthread = NULL;
+#ifdef NOT_YET
 				kse->k_kseg->kg_flags |= KGF_SINGLE_THREAD;
+#endif
 				new_thread->kse = kse;
 				new_thread->kseg = kse->k_kseg;
 				kse->k_mbx.km_udata = kse;
 				kse->k_mbx.km_curthread = NULL;
 			}
+
+			crit = _kse_critical_enter();
 			KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock);
-
 			/*
 			 * Initialise the unique id which GDB uses to
 			 * track threads.
 			 */
 			new_thread->uniqueid = next_uniqueid++;
-
 			/* Add the thread to the linked list of all threads: */
 			THR_LIST_ADD(new_thread);
-
 			KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock);
 
 			/*
@@ -269,15 +296,12 @@
 			 * pair if necessary.
 			 */
 			_thr_schedule_add(curthread, new_thread);
+			_kse_critical_leave(crit);
 
 			/* Return a pointer to the thread structure: */
 			(*thread) = new_thread;
 		}
 	}
-	_kse_critical_leave(crit);
-
-	if ((ret == 0) && (_kse_isthreaded() == 0))
-		_kse_setthreaded(1);
 
 	/* Return the status: */
 	return (ret);

==== //depot/projects/ia64_epc/lib/libpthread/thread/thr_kern.c#4 (text+ko) ====

@@ -33,7 +33,7 @@
  *
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libpthread/thread/thr_kern.c,v 1.54 2003/04/18 07:45:03 deischen Exp $");
+__FBSDID("$FreeBSD: src/lib/libpthread/thread/thr_kern.c,v 1.55 2003/04/21 04:02:56 deischen Exp $");
 
 #include <sys/types.h>
 #include <sys/kse.h>
@@ -94,6 +94,14 @@
 	_pq_remove(&(kse)->k_schedq->sq_runq, thrd)
 #define	KSE_RUNQ_FIRST(kse)	_pq_first(&(kse)->k_schedq->sq_runq)
 
+/*
+ * XXX - Remove when David commits kernel changes to support these.
+ */
+#ifndef KMF_NOUPCALL
+#define	KMF_NOUPCALL	0x01
+#define	KMF_NOCOMPLETED	0x02
+#endif
+
 
 /*
  * We've got to keep track of everything that is allocated, not only
@@ -118,15 +126,17 @@
 static void	kse_check_completed(struct kse *kse);
 static void	kse_check_waitq(struct kse *kse);
 static void	kse_check_signals(struct kse *kse);
-static void	kse_entry(struct kse_mailbox *mbx);
 static void	kse_fini(struct kse *curkse);
 static void	kse_sched_multi(struct kse *curkse);
+#ifdef NOT_YET
 static void	kse_sched_single(struct kse *curkse);
+#endif
 static void	kse_switchout_thread(struct kse *kse, struct pthread *thread);
-static void	kse_wait(struct kse *kse);
+static void	kse_wait(struct kse *kse, struct pthread *td_wait);
 static void	kse_free_unlocked(struct kse *kse);
 static void	kseg_free(struct kse_group *kseg);
 static void	kseg_init(struct kse_group *kseg);
+static void	kseg_reinit(struct kse_group *kseg);
 static void	kse_waitq_insert(struct pthread *thread);
 static void	thr_cleanup(struct kse *kse, struct pthread *curthread);
 #ifdef NOT_YET
@@ -203,6 +213,8 @@
 	while ((kse = TAILQ_FIRST(&free_kseq)) != NULL) {
 		TAILQ_REMOVE(&free_kseq, kse, k_qe);
 		_ksd_destroy(&kse->k_ksd);
+		if (kse->k_stack.ss_sp != NULL)
+			free(kse->k_stack.ss_sp);
 		free(kse);
 	}
 	free_kse_count = 0;
@@ -214,6 +226,8 @@
 		for (i = 0; i < MAX_KSE_LOCKLEVEL; i++) {
 			_lockuser_destroy(&kse->k_lockusers[i]);
 		}
+		if (kse->k_stack.ss_sp != NULL)
+			free(kse->k_stack.ss_sp);
 		_lock_destroy(&kse->k_lock);
 		free(kse);
 	}
@@ -331,7 +345,7 @@
  * This is called when the first thread (other than the initial
  * thread) is created.
  */
-void
+int
 _kse_setthreaded(int threaded)
 {
 	if ((threaded != 0) && (__isthreaded == 0)) {
@@ -345,9 +359,16 @@
 		 * Tell the kernel to create a KSE for the initial thread
 		 * and enable upcalls in it.
 		 */
-		kse_create(&_kse_initial->k_mbx, 0);
+		_kse_initial->k_flags |= KF_STARTED;
+		if (kse_create(&_kse_initial->k_mbx, 0) != 0) {
+			_kse_initial->k_flags &= ~KF_STARTED;
+			/* may abort() */
+			DBG_MSG("kse_create failed\n");
+			return (-1);
+		}
 		KSE_SET_MBOX(_kse_initial, _thr_initial);
 	}
+	return (0);
 }
 
 /*
@@ -367,8 +388,10 @@
 {
 	struct kse *curkse = (struct kse *)_LCK_GET_PRIVATE(lu);
 	struct timespec ts;
-	kse_critical_t crit;
+	int saved_flags;
 
+	if (curkse->k_mbx.km_curthread != NULL)
+		PANIC("kse_lock_wait does not disable upcall.\n");
 	/*
 	 * Enter a loop to wait until we get the lock.
 	 */
@@ -380,9 +403,10 @@
 		 * Yield the kse and wait to be notified when the lock
 		 * is granted.
 		 */
-		crit = _kse_critical_enter();
-		__sys_nanosleep(&ts, NULL);
-		_kse_critical_leave(crit);
+		saved_flags = curkse->k_mbx.km_flags;
+		curkse->k_mbx.km_flags |= KMF_NOUPCALL;
+		kse_release(&ts);
+		curkse->k_mbx.km_flags = saved_flags;
 
 		/*
 		 * Make sure that the wait flag is set again in case
@@ -537,38 +561,6 @@
 }
 
 /*
- * This is the entry point of the KSE upcall.
- */
-static void
-kse_entry(struct kse_mailbox *mbx)
-{
-	struct kse *curkse;
-
-	/* The kernel should always clear this before making the upcall. */
-	assert(mbx->km_curthread == NULL);
-	curkse = (struct kse *)mbx->km_udata;
-
-	/* Check for first time initialization: */
-	if ((curkse->k_flags & KF_INITIALIZED) == 0) {
-		/* Setup this KSEs specific data. */
-		_ksd_setprivate(&curkse->k_ksd);
-		_set_curkse(curkse);
-
-		/* Set this before grabbing the context. */
-		curkse->k_flags |= KF_INITIALIZED;
-	}
-
-	/* Avoid checking the type of KSE more than once. */
-	if ((curkse->k_kseg->kg_flags & KGF_SINGLE_THREAD) != 0) {
-		curkse->k_mbx.km_func = (void *)kse_sched_single;
-		kse_sched_single(curkse);
-	} else {
-		curkse->k_mbx.km_func = (void *)kse_sched_multi;
-		kse_sched_multi(curkse);
-	}
-}
-
-/*
  * This is the scheduler for a KSE which runs a scope system thread.
  * The multi-thread KSE scheduler should also work for a single threaded
  * KSE, but we use a separate scheduler so that it can be fine-tuned
@@ -577,19 +569,15 @@
  *
  * XXX - This probably needs some work.
  */
+#ifdef NOT_YET
 static void
 kse_sched_single(struct kse *curkse)
 {
-	struct pthread *curthread;
+	struct pthread *curthread = curkse->k_curthread;
+	struct pthread *td_wait;
 	struct timespec ts;
 	int level;
 
-	/* This may have returned from a kse_release(). */
-	if (KSE_WAITING(curkse))
-		KSE_CLEAR_WAIT(curkse);
-
-	curthread = curkse->k_curthread;
-
 	if (curthread->active == 0) {
 		if (curthread->state != PS_RUNNING) {
 			/* Check to see if the thread has timed out. */
@@ -599,68 +587,83 @@
 				curthread->state = PS_RUNNING;
 			}
 		}
-	} else if (curthread->need_switchout != 0) {
-		/*
-		 * This has to do the job of kse_switchout_thread(), only
-		 * for a single threaded KSE/KSEG.
-		 */
+	}
+
+	/* This thread no longer needs to yield the CPU: */
+	curthread->critical_yield = 0;
+	curthread->need_switchout = 0;
+
+	/*
+	 * Lock the scheduling queue.
+	 *
+	 * There is no scheduling queue for single threaded KSEs,
+	 * but we need a lock for protection regardless.
+	 */
+	KSE_SCHED_LOCK(curkse, curkse->k_kseg);
+
+	/*
+	 * This has to do the job of kse_switchout_thread(), only
+	 * for a single threaded KSE/KSEG.
+	 */
+
+	switch (curthread->state) {
+	case PS_DEAD:
+		/* Unlock the scheduling queue and exit the KSE. */
+		KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
+		kse_fini(curkse);	/* does not return */
+		break;
+
+	case PS_COND_WAIT:
+	case PS_SLEEP_WAIT:
+		/* Only insert threads that can timeout: */
+		if (curthread->wakeup_time.tv_sec != -1) {
+			/* Insert into the waiting queue: */
+			KSE_WAITQ_INSERT(curkse, curthread);
+		}
+		break;
 
-		/* This thread no longer needs to yield the CPU: */
-		curthread->critical_yield = 0;
-		curthread->need_switchout = 0;
+	case PS_LOCKWAIT:
+		level = curthread->locklevel - 1;
+		if (_LCK_BUSY(&curthread->lockusers[level]))
+			KSE_WAITQ_INSERT(curkse, curthread);
+		else
+			THR_SET_STATE(curthread, PS_RUNNING);
+		break;
 
+	case PS_JOIN:
+	case PS_MUTEX_WAIT:
+	case PS_RUNNING:
+	case PS_SIGSUSPEND:
+	case PS_SIGWAIT:
+	case PS_SUSPENDED:
+	case PS_DEADLOCK:
+	default:
 		/*
-		 * Lock the scheduling queue.
-		 *
-		 * There is no scheduling queue for single threaded KSEs,
-		 * but we need a lock for protection regardless.
+		 * These states don't timeout and don't need
+		 * to be in the waiting queue.
 		 */
-		KSE_SCHED_LOCK(curkse, curkse->k_kseg);
+		break;
+	}
+	while (curthread->state != PS_RUNNING) {
+		curthread->active = 0;
+		td_wait = KSE_WAITQ_FIRST(curkse);
+
+		kse_wait(curkse, td_wait);
 
-		switch (curthread->state) {
-		case PS_DEAD:
-			/* Unlock the scheduling queue and exit the KSE. */
-			KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
-			kse_fini(curkse);	/* does not return */
-			break;
+	    	if (td_wait != NULL) {
+			KSE_GET_TOD(curkse, &ts);
+			if (thr_timedout(curthread, &ts)) {
+				/* Indicate the thread timedout: */
+				td_wait->timeout = 1;
 
-		case PS_COND_WAIT:
-		case PS_SLEEP_WAIT:
-			/* Only insert threads that can timeout: */
-			if (curthread->wakeup_time.tv_sec != -1) {
-				/* Insert into the waiting queue: */
-				KSE_WAITQ_INSERT(curkse, curthread);
+				/* Make the thread runnable. */
+				THR_SET_STATE(td_wait, PS_RUNNING);
+				KSE_WAITQ_REMOVE(curkse, td_wait);
 			}
-			break;
-
-		case PS_LOCKWAIT:
-			level = curthread->locklevel - 1;
-			if (_LCK_BUSY(&curthread->lockusers[level]))
-				KSE_WAITQ_INSERT(curkse, curthread);
-			else
-				THR_SET_STATE(curthread, PS_RUNNING);
-			break;
-
-		case PS_JOIN:
-		case PS_MUTEX_WAIT:
-		case PS_RUNNING:
-		case PS_SIGSUSPEND:
-		case PS_SIGWAIT:
-		case PS_SUSPENDED:
-		case PS_DEADLOCK:
-		default:
-			/*
-			 * These states don't timeout and don't need
-			 * to be in the waiting queue.
-			 */
-			break;
 		}
-		if (curthread->state != PS_RUNNING)
-			curthread->active = 0;
-	}
-
-	while (curthread->state != PS_RUNNING) {
-		kse_wait(curkse);
+		KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
+		kse_check_signals(curkse);
+		KSE_SCHED_LOCK(curkse, curkse->k_kseg);
 	}
 
 	/* Remove the frame reference. */
@@ -672,8 +675,11 @@
 	/*
 	 * Continue the thread at its current frame:
 	 */
+	DBG_MSG("Continuing bound thread %p\n", curthread);
 	_thread_switch(&curthread->tmbx, &curkse->k_mbx.km_curthread);
+	PANIC("Thread has returned from _thread_switch");
 }
+#endif
 
 void
 dump_queues(struct kse *curkse)
@@ -687,17 +693,26 @@
 	}
 }
 
-
 /*
  * This is the scheduler for a KSE which runs multiple threads.
  */
 static void
 kse_sched_multi(struct kse *curkse)
 {
-	struct pthread *curthread;
+	struct pthread *curthread, *td_wait;
 	struct pthread_sigframe *curframe;
 	int ret;
 
+	/* Check for first time initialization: */
+	if ((curkse->k_flags & KF_INITIALIZED) == 0) {
+		/* Setup this KSEs specific data. */
+		_ksd_setprivate(&curkse->k_ksd);
+		_set_curkse(curkse);
+
+		/* Set this before grabbing the context. */
+		curkse->k_flags |= KF_INITIALIZED;
+	}
+
 	/* This may have returned from a kse_release(). */
 	if (KSE_WAITING(curkse))
 		KSE_CLEAR_WAIT(curkse);
@@ -774,7 +789,9 @@
 		 * Wait for a thread to become active or until there are
 		 * no more threads.
 		 */
-		kse_wait(curkse);
+		td_wait = KSE_WAITQ_FIRST(curkse);
+		kse_wait(curkse, td_wait);
+		kse_check_completed(curkse);
 		kse_check_waitq(curkse);
 		KSE_SCHED_UNLOCK(curkse, curkse->k_kseg);
 		kse_check_signals(curkse);
@@ -852,10 +869,13 @@
 		    (__sighandler_t *)thr_resume_wrapper);
 	}
 #endif
+#ifdef GS_HACK
+	/* XXX - The kernel sometimes forgets to restore %gs properly. */
+	_ksd_setprivate(&curkse->k_ksd);
+#endif
 	/*
 	 * Continue the thread at its current frame:
 	 */
-	DBG_MSG("Continuing thread %p\n", curthread);
 	ret = _thread_switch(&curthread->tmbx, &curkse->k_mbx.km_curthread);
 	if (ret != 0)
 		PANIC("Thread has returned from _thread_switch");
@@ -993,8 +1013,9 @@
 {
 	struct pthread *td, *td_next;
 	kse_critical_t crit;
-	int clean;
+	TAILQ_HEAD(, pthread) worklist;
 
+	TAILQ_INIT(&worklist);
 	crit = _kse_critical_enter();
 	KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock);
 
@@ -1014,28 +1035,45 @@
 			continue;
 		}
 #endif
+		/*
+		 * Remove the thread from the GC list.  If the thread
+		 * isn't yet detached, it will get added back to the
+		 * GC list at a later time.
+		 */
 		THR_GCLIST_REMOVE(td);
-		clean = ((td->attr.flags & PTHREAD_DETACHED) != 0) &&
-		    (td->refcount == 0);
+		DBG_MSG("Freeing thread %p stack\n", td);
+		/*
+		 * We can free the thread stack since it's no longer
+		 * in use.
+		 */
 		_thr_stack_free(&td->attr);
-		KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock);
-		DBG_MSG("Found thread %p in GC list, clean? %d\n", td, clean);
+		if (((td->attr.flags & PTHREAD_DETACHED) != 0) &&
+		    (td->refcount == 0)) {
+			/*
+			 * The thread has detached and is no longer
+			 * referenced.  It is safe to remove all
+			 * remnants of the thread.
+			 */
+			TAILQ_INSERT_HEAD(&worklist, td, gcle);
+		}
+	}
+	KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock);
+	_kse_critical_leave(crit);
+
+	while ((td = TAILQ_FIRST(&worklist)) != NULL) {
+		TAILQ_REMOVE(&worklist, td, gcle);
 
 		if ((td->attr.flags & PTHREAD_SCOPE_PROCESS) != 0) {
+			crit = _kse_critical_enter();
 			KSE_LOCK_ACQUIRE(curthread->kse, &kse_lock);
 			kse_free_unlocked(td->kse);
 			kseg_free(td->kseg);
 			KSE_LOCK_RELEASE(curthread->kse, &kse_lock);
-		}
-		if (clean != 0) {
 			_kse_critical_leave(crit);
-			_thr_free(curthread, td);
-			crit = _kse_critical_enter();
 		}
-		KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock);
+		DBG_MSG("Freeing thread %p\n", td);
+		_thr_free(curthread, td);
 	}
-	KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock);
-	_kse_critical_leave(crit);
 }

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304220224.h3M2OuFl047689>