From owner-p4-projects@FreeBSD.ORG Sun Mar 28 13:15:53 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9793A16A4D5; Sun, 28 Mar 2004 13:15:53 -0800 (PST) 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 3D65116A4CF for ; Sun, 28 Mar 2004 13:15:53 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 33BBC43D46 for ; Sun, 28 Mar 2004 13:15:53 -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 i2SLFrGe015352 for ; Sun, 28 Mar 2004 13:15:53 -0800 (PST) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i2SLFq1C015349 for perforce@freebsd.org; Sun, 28 Mar 2004 13:15:52 -0800 (PST) (envelope-from marcel@freebsd.org) Date: Sun, 28 Mar 2004 13:15:52 -0800 (PST) Message-Id: <200403282115.i2SLFq1C015349@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 49848 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: Sun, 28 Mar 2004 21:15:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=49848 Change 49848 by marcel@marcel_nfs on 2004/03/28 13:15:17 Commit to adding thread IDs. Threads create as part of a fork will inherit the process ID as before. Threads created by 1:1 or M:N threading will get an ID in a seperate range so that they won't affect or conflict with process creation. Add thread_new_tid() to assign new thread IDs. Provide a place holder for now. Move the td_tid field out of the zero range. It now needs to be set explicitly. Affected files ... .. //depot/projects/gdb/sys/kern/kern_fork.c#8 edit .. //depot/projects/gdb/sys/kern/kern_thr.c#3 edit .. //depot/projects/gdb/sys/kern/kern_thread.c#6 edit .. //depot/projects/gdb/sys/sys/proc.h#8 edit Differences ... ==== //depot/projects/gdb/sys/kern/kern_fork.c#8 (text+ko) ==== @@ -497,8 +497,8 @@ (unsigned) RANGEOF(struct ksegrp, kg_startcopy, kg_endcopy)); #undef RANGEOF + td2->td_tid = p2->p_pid; td2->td_sigstk = td->td_sigstk; - td2->td_tid = p2->p_pid; /* Set up the thread as an active thread (as if runnable). */ ke2->ke_state = KES_THREAD; ==== //depot/projects/gdb/sys/kern/kern_thr.c#3 (text+ko) ==== @@ -133,6 +133,7 @@ /* Initialize our td. */ td0 = thread_alloc(); + td0->td_tid = thread_new_tid(); /* * Try the copyout as soon as we allocate the td so we don't have to ==== //depot/projects/gdb/sys/kern/kern_thread.c#6 (text+ko) ==== @@ -1032,6 +1032,17 @@ } /* + * Assign a thread ID between 100000 and 999999. + */ +int +thread_new_tid(void) +{ + static int next_tid = 100000; + + return (next_tid++); +} + +/* * Store the thread context in the UTS's mailbox. * then add the mailbox at the head of a list we are building in user space. * The list is anchored in the ksegrp structure. @@ -1472,8 +1483,10 @@ if (td->td_standin) return; - if (spare == NULL) + if (spare == NULL) { spare = thread_alloc(); + spare->td_tid = thread_new_tid(); + } td->td_standin = spare; bzero(&spare->td_startzero, (unsigned)RANGEOF(struct thread, td_startzero, td_endzero)); ==== //depot/projects/gdb/sys/sys/proc.h#8 (text+ko) ==== @@ -145,6 +145,7 @@ * p - select lock (sellock) * q - td_contested lock * r - p_peers lock + * t - updated at kernel (re)entry. Read-only in all other cases. * x - created at fork, only changes during single threading in exec * z - zombie threads/kse/ksegroup lock * @@ -268,14 +269,14 @@ TAILQ_HEAD(, selinfo) td_selq; /* (p) List of selinfos. */ struct sleepqueue *td_sleepqueue; /* (k) Associated sleep queue. */ struct turnstile *td_turnstile; /* (k) Associated turnstile. */ + int td_tid; /* (b) Thread ID. */ /* Cleared during fork1() or thread_sched_upcall(). */ #define td_startzero td_flags int td_flags; /* (j) TDF_* flags. */ int td_inhibitors; /* (j) Why can not run. */ int td_pflags; /* (k) Private thread (TDP_*) flags. */ - int td_tid; /* XXX currently unused. */ - struct trapframe *td_last_frame; + struct trapframe *td_last_frame; /* (t) Trapframe of last entry. */ struct kse *td_last_kse; /* (j) Previous value of td_kse. */ struct kse *td_kse; /* (j) Current KSE if running. */ int td_dupfd; /* (k) Ret value from fdopen. XXX */ @@ -905,6 +906,7 @@ int thread_export_context(struct thread *td, int willexit); void thread_free(struct thread *td); void thread_link(struct thread *td, struct ksegrp *kg); +int thread_new_tid(void); void thread_reap(void); struct thread *thread_schedule_upcall(struct thread *td, struct kse_upcall *ku); int thread_single(int how);