cvs commit: src/sys/kern kern_fork.c kern_thr.c kern_thread.c src/sys/sys proc.h

Marcel Moolenaar marcel at FreeBSD.org
Sat Apr 3 07:59:16 PST 2004


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


More information about the cvs-src mailing list