Date: Sat, 3 Apr 2004 07:59:13 -0800 (PST) From: Marcel Moolenaar <marcel@FreeBSD.org> 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 Message-ID: <200404031559.i33FxDMt085916@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404031559.i33FxDMt085916>