From owner-p4-projects@FreeBSD.ORG Mon Jun 28 04:34:56 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F35AA16A4D1; Mon, 28 Jun 2004 04:34:55 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B9F4A16A4CE for ; Mon, 28 Jun 2004 04:34:55 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9DA4F43D1D for ; Mon, 28 Jun 2004 04:34:55 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i5S4Yt2Y034417 for ; Mon, 28 Jun 2004 04:34:55 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i5S4Ytpg034414 for perforce@freebsd.org; Mon, 28 Jun 2004 04:34:55 GMT (envelope-from marcel@freebsd.org) Date: Mon, 28 Jun 2004 04:34:55 GMT Message-Id: <200406280434.i5S4Ytpg034414@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 55973 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2004 04:34:57 -0000 http://perforce.freebsd.org/chv.cgi?CH=55973 Change 55973 by marcel@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 */