PERFORCE change 55973 for review

Marcel Moolenaar marcel at FreeBSD.org
Sun Jun 27 21:34:57 PDT 2004


http://perforce.freebsd.org/chv.cgi?CH=55973

Change 55973 by marcel at marcel_nfs on 2004/06/28 04:34:18

	Have libthr() call getlwpid() and save the LWP in the thread
	structure. Rename uniqueid to lwpid. The use of uniqueid was
	simply copied from libc_r.
	
	Note that libthr uses a thread id (thr_id_t) that is the
	address of the kernel thread structure. This can be replaced
	in its entirety by using the lwpid. There is not performance
	loss. However, changing that would change the thr_* syscalls
	as well as the umtx_* functions and syscalls. This is a
	major ABI breakage and thus is not done.

Affected files ...

.. //depot/projects/gdb/lib/libthr/thread/thr_cond.c#5 edit
.. //depot/projects/gdb/lib/libthr/thread/thr_create.c#5 edit
.. //depot/projects/gdb/lib/libthr/thread/thr_init.c#5 edit
.. //depot/projects/gdb/lib/libthr/thread/thr_mutex.c#6 edit
.. //depot/projects/gdb/lib/libthr/thread/thr_private.h#7 edit

Differences ...

==== //depot/projects/gdb/lib/libthr/thread/thr_cond.c#5 (text+ko) ====

@@ -440,10 +440,10 @@
 	name = pthread->name ? pthread->name : "unknown";
 	if ((pthread->flags & PTHREAD_FLAGS_IN_CONDQ) != 0)
 		_thread_printf(2, "Thread (%s:%u) already on condq\n",
-		    pthread->name, pthread->uniqueid);
+		    pthread->name, pthread->lwpid);
 	if ((pthread->flags & PTHREAD_FLAGS_IN_MUTEXQ) != 0)
 		_thread_printf(2, "Thread (%s:%u) already on mutexq\n",
-		    pthread->name, pthread->uniqueid);
+		    pthread->name, pthread->lwpid);
 	PTHREAD_ASSERT_NOT_IN_SYNCQ(pthread);
 
 	/*

==== //depot/projects/gdb/lib/libthr/thread/thr_create.c#5 (text+ko) ====

@@ -43,11 +43,9 @@
 #include "thr_private.h"
 #include "libc_private.h"
 
-static u_int64_t next_uniqueid = 1;
-
 #define OFF(f)	offsetof(struct pthread, f)
 int _thread_next_offset			= OFF(tle.tqe_next);
-int _thread_uniqueid_offset		= OFF(uniqueid);
+int _thread_lwpid_offset		= OFF(lwpid);
 int _thread_name_offset			= OFF(name);
 int _thread_ctx_offset			= OFF(ctx);
 #undef OFF
@@ -137,12 +135,6 @@
 	}
 	new_thread->active_priority = new_thread->base_priority;
 
-	/*
-	 * Initialise the unique id which GDB uses to
-	 * track threads.
-	 */
-	new_thread->uniqueid = next_uniqueid++;
-
 	THREAD_LIST_LOCK;
 
 	/* Add the thread to the linked list of all threads: */
@@ -178,6 +170,9 @@
 _thread_start(void)
 {
 
+	/* Initialise the unique id which GDB uses to track threads. */
+	curthread->lwpid = getlwpid();
+
 	/* Run the current thread's start routine with argument: */
 	pthread_exit(curthread->start_routine(curthread->arg));
 

==== //depot/projects/gdb/lib/libthr/thread/thr_init.c#5 (text+ko) ====

@@ -304,6 +304,7 @@
 
 	/* Get our thread id. */
 	thr_self(&pthread->thr_id);
+	pthread->lwpid = getlwpid();
 
 	/* Find the stack top */
 	mib[0] = CTL_KERN;

==== //depot/projects/gdb/lib/libthr/thread/thr_mutex.c#6 (text+ko) ====

@@ -800,10 +800,10 @@
 	name = pthread->name ? pthread->name : "unknown";
 	if ((pthread->flags & PTHREAD_FLAGS_IN_CONDQ) != 0)
 		_thread_printf(2, "Thread (%s:%u) already on condq\n",
-		    pthread->name, pthread->uniqueid);
+		    pthread->name, pthread->lwpid);
 	if ((pthread->flags & PTHREAD_FLAGS_IN_MUTEXQ) != 0)
 		_thread_printf(2, "Thread (%s:%u) already on mutexq\n",
-		    pthread->name, pthread->uniqueid);
+		    pthread->name, pthread->lwpid);
 	PTHREAD_ASSERT_NOT_IN_SYNCQ(pthread);
 	/*
 	 * For the common case of all threads having equal priority,

==== //depot/projects/gdb/lib/libthr/thread/thr_private.h#7 (text+ko) ====

@@ -470,8 +470,8 @@
 	 */
 #define	PTHREAD_MAGIC		((u_int32_t) 0xd09ba115)
 	u_int32_t		magic;
+	lwpid_t			lwpid; /* for gdb */
 	char			*name;
-	u_int64_t		uniqueid; /* for gdb */
 	thr_id_t		thr_id;
 	sigset_t		savedsig;
 	int			signest; /* blocked signal netsting level */


More information about the p4-projects mailing list