summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2003-04-18 00:16:13 +0000
committerjulian <julian@FreeBSD.org>2003-04-18 00:16:13 +0000
commit0e096a3dd163c27944c9b093848e512ae4954d04 (patch)
treeb465081feb462d7e46cfb9b2b9f85de50af4fec7 /sys
parent5c54a6ed57f16b5abad741cd6e4e2386a01ec61c (diff)
downloadFreeBSD-src-0e096a3dd163c27944c9b093848e512ae4954d04.zip
FreeBSD-src-0e096a3dd163c27944c9b093848e512ae4954d04.tar.gz
Add a thread_unlink() and use it.
It could also be used twice in kern_thr.c but that's owned by jeff so I'l let him change it when he's next there.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_kse.c25
-rw-r--r--sys/kern/kern_thread.c25
-rw-r--r--sys/sys/proc.h1
3 files changed, 29 insertions, 22 deletions
diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c
index 784d45b..5f03369 100644
--- a/sys/kern/kern_kse.c
+++ b/sys/kern/kern_kse.c
@@ -1198,17 +1198,7 @@ thread_exit(void)
* all this stuff.
*/
if (p->p_numthreads > 1) {
- /*
- * Unlink this thread from its proc and the kseg.
- * In keeping with the other structs we probably should
- * have a thread_unlink() that does some of this but it
- * would only be called from here (I think) so it would
- * be a waste. (might be useful for proc_fini() as well.)
- */
- TAILQ_REMOVE(&p->p_threads, td, td_plist);
- p->p_numthreads--;
- TAILQ_REMOVE(&kg->kg_threads, td, td_kglist);
- kg->kg_numthreads--;
+ thread_unlink(td);
if (p->p_maxthrwaits)
wakeup(&p->p_numthreads);
/*
@@ -1315,6 +1305,19 @@ thread_link(struct thread *td, struct ksegrp *kg)
kg->kg_numthreads++;
}
+void
+thread_unlink(struct thread *td)
+{
+ struct proc *p = td->td_proc;
+ struct ksegrp *kg = td->td_ksegrp;
+
+ TAILQ_REMOVE(&p->p_threads, td, td_plist);
+ p->p_numthreads--;
+ TAILQ_REMOVE(&kg->kg_threads, td, td_kglist);
+ kg->kg_numthreads--;
+ /* could clear a few other things here */
+}
+
/*
* Purge a ksegrp resource. When a ksegrp is preparing to
* exit, it calls this function.
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 784d45b..5f03369 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -1198,17 +1198,7 @@ thread_exit(void)
* all this stuff.
*/
if (p->p_numthreads > 1) {
- /*
- * Unlink this thread from its proc and the kseg.
- * In keeping with the other structs we probably should
- * have a thread_unlink() that does some of this but it
- * would only be called from here (I think) so it would
- * be a waste. (might be useful for proc_fini() as well.)
- */
- TAILQ_REMOVE(&p->p_threads, td, td_plist);
- p->p_numthreads--;
- TAILQ_REMOVE(&kg->kg_threads, td, td_kglist);
- kg->kg_numthreads--;
+ thread_unlink(td);
if (p->p_maxthrwaits)
wakeup(&p->p_numthreads);
/*
@@ -1315,6 +1305,19 @@ thread_link(struct thread *td, struct ksegrp *kg)
kg->kg_numthreads++;
}
+void
+thread_unlink(struct thread *td)
+{
+ struct proc *p = td->td_proc;
+ struct ksegrp *kg = td->td_ksegrp;
+
+ TAILQ_REMOVE(&p->p_threads, td, td_plist);
+ p->p_numthreads--;
+ TAILQ_REMOVE(&kg->kg_threads, td, td_kglist);
+ kg->kg_numthreads--;
+ /* could clear a few other things here */
+}
+
/*
* Purge a ksegrp resource. When a ksegrp is preparing to
* exit, it calls this function.
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 1761f5f..aad20aa 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -943,6 +943,7 @@ void thread_single_end(void);
void thread_stash(struct thread *td);
int thread_suspend_check(int how);
void thread_suspend_one(struct thread *td);
+void thread_unlink(struct thread *td);
void thread_unsuspend(struct proc *p);
void thread_unsuspend_one(struct thread *td);
int thread_userret(struct thread *td, struct trapframe *frame);
OpenPOWER on IntegriCloud