From owner-freebsd-threads@FreeBSD.ORG Tue Apr 13 18:44:21 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0ADE116A4CE for ; Tue, 13 Apr 2004 18:44:21 -0700 (PDT) Received: from exchhz01.viatech.com.cn (ip-40-162-97-218.anlai.com [218.97.162.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id A8C2A43D58 for ; Tue, 13 Apr 2004 18:44:10 -0700 (PDT) (envelope-from davidxu@freebsd.org) Received: from freebsd.org (DAVIDWNT [10.4.1.99]) by exchhz01.viatech.com.cn with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id 2KSL2K9Q; Wed, 14 Apr 2004 09:35:02 +0800 Message-ID: <407C9584.10805@freebsd.org> Date: Wed, 14 Apr 2004 09:36:04 +0800 From: David Xu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5b) Gecko/20030723 Thunderbird/0.1 X-Accept-Language: en-us, en MIME-Version: 1.0 To: threads@FreeBSD.org Content-Type: multipart/mixed; boundary="------------060209070405000405090909" Subject: [Fwd: cvs commit: src/sys/kern kern_fork.c kern_thr.c kern_thread.c src/sys/sys proc.h] X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Apr 2004 01:44:21 -0000 This is a multi-part message in MIME format. --------------060209070405000405090909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This commit would change the way how gdb searches a thread by using ptrace interface in my thread debugging patch: http://people.freebsd.org/~davidxu/kse/thread_db the patch is now supporting libpthread and libthr, however because libthr is using another type of thread identify thr_id_t, if I follow the commit, the patch won't work, libthr and its interfaces need to be changed to use integer tid, libpthread won't be affected because it never uses kernel thread id. David Xu --------------060209070405000405090909 Content-Type: message/rfc822;src/sys/sysproc.h" Content-Transfer-Encoding: 7bit Content-Disposition: inline;kern_thread.c src/sys/sysproc.h" Received: from exchange.via.com.tw (EXCHANGE [202.145.217.203]) by exchhz01.viatech.com.cn with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id HNTCCTWQ; Sun, 4 Apr 2004 00:01:21 +0800 Received: by exchange.vntek.com.tw with Internet Mail Service (5.5.2650.21) id ; Sun, 4 Apr 2004 00:00:39 +0800 Received: from exchsh01.viatech.com.cn (ip-33-237-104-152.anlai.com [152.104.237.33]) by exchange.via.com.tw with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id G6LCKB6Y; Sun, 4 Apr 2004 00:00:37 +0800 Received: by exchsh01.viatech.com.cn with Internet Mail Service (5.5.2653.19) id ; Sun, 4 Apr 2004 00:00:53 +0800 Received: from mx2.freebsd.org ([216.136.204.119]) by exchsh01.viatech.com.cn with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id HZZH4KSZ; Sun, 4 Apr 2004 00:00:52 +0800 Received: from hub.freebsd.org (hub.freebsd.org [216.136.204.18]) by mx2.freebsd.org (Postfix) with ESMTP id E821657680; Sat, 3 Apr 2004 07:59:33 -0800 (PST) (envelope-from owner-src-committers@FreeBSD.org) Received: by hub.freebsd.org (Postfix) id D3D2316A509; Sat, 3 Apr 2004 07:59:27 -0800 (PST) Received: by hub.freebsd.org (Postfix, from userid 538) id 7D7C816A4D1; Sat, 3 Apr 2004 07:59:27 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5FD1016A4CE; Sat, 3 Apr 2004 07:59:16 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 586D843D2F; Sat, 3 Apr 2004 07:59:16 -0800 (PST) (envelope-from marcel@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i33FxDGe085917; Sat, 3 Apr 2004 07:59:13 -0800 (PST) (envelope-from marcel@repoman.freebsd.org) Received: (from marcel@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i33FxDMt085916; Sat, 3 Apr 2004 07:59:13 -0800 (PST) (envelope-from marcel) Delivered-To: davidxu@freebsd.org Delivered-To: src-committers@freebsd.org Message-Id: <200404031559.i33FxDMt085916@repoman.freebsd.org> From: Marcel Moolenaar Date: Sat, 3 Apr 2004 07:59:13 -0800 (PST) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/sys/kern kern_fork.c kern_thr.c kern_thread.c src/sys/sys proc.h X-FreeBSD-CVS-Branch: HEAD Sender: owner-src-committers@FreeBSD.org Precedence: bulk X-Loop: FreeBSD.ORG marcel 2004/04/03 07:59:13 PST FreeBSD src repository Modified files: sys/kern kern_fork.c kern_thr.c kern_thread.c sys/sys proc.h Log: Assign thread IDs to kernel threads. The purpose of the thread ID (tid) is twofold: 1. When a 1:1 or M:N threaded process dumps core, we need to put the register state of each of its kernel threads in the core file. This can only be done by differentiating the pid field in the respective note. For this we need the tid. 2. When thread support is present for remote debugging the kernel with gdb(1), threads need to be identified by an integer due to limitations in the remote protocol. This requires having a tid. To minimize the impact of having thread IDs, threads that are created as part of a fork (i.e. the initial thread in a process) will inherit the process ID (i.e. tid=pid). Subsequent threads will have IDs larger than PID_MAX to avoid interference with the pid allocation algorithm. The assignment of tids is handled by thread_new_tid(). The thread ID allocation algorithm has been written with 3 assumptions in mind: 1. IDs need to be created as fast a possible, 2. Reuse of IDs may happen instantaneously, 3. Someone else will write a better algorithm. Revision Changes Path 1.225 +1 -0 src/sys/kern/kern_fork.c 1.18 +1 -0 src/sys/kern/kern_thr.c 1.175 +98 -2 src/sys/kern/kern_thread.c 1.373 +2 -0 src/sys/sys/proc.h --------------060209070405000405090909--