Date: Sun, 28 Mar 2004 13:15:52 -0800 (PST) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 49848 for review Message-ID: <200403282115.i2SLFq1C015349@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403282115.i2SLFq1C015349>