diff options
author | David Xu <davidxu@FreeBSD.org> | 2005-11-03 01:34:08 +0000 |
---|---|---|
committer | David Xu <davidxu@FreeBSD.org> | 2005-11-03 01:34:08 +0000 |
commit | 44355392b440219f792eb3ba326fc3aa0a63bd1f (patch) | |
tree | 2e7593b1e0b58fad914db0320d327f10c9f50256 /sys/kern/kern_thr.c | |
parent | 9af9b983e10e5b2e0985524f99b8b306c907a2d8 (diff) | |
download | src-44355392b440219f792eb3ba326fc3aa0a63bd1f.tar.gz src-44355392b440219f792eb3ba326fc3aa0a63bd1f.zip |
Add thread_find() function to search a thread by lwpid.
Notes
Notes:
svn path=/head/; revision=151990
Diffstat (limited to 'sys/kern/kern_thr.c')
-rw-r--r-- | sys/kern/kern_thr.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 39817df9c119..6b676722ac37 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -310,10 +310,7 @@ thr_kill(struct thread *td, struct thr_kill_args *uap) p = td->td_proc; error = 0; PROC_LOCK(p); - FOREACH_THREAD_IN_PROC(p, ttd) { - if (ttd->td_tid == uap->id) - break; - } + ttd = thread_find(p, uap->id); if (ttd == NULL) { error = ESRCH; goto out; @@ -324,7 +321,7 @@ thr_kill(struct thread *td, struct thr_kill_args *uap) error = EINVAL; goto out; } - tdsignal(ttd, uap->sig, NULL, SIGTARGET_TD); + tdsignal(p, ttd, uap->sig, NULL); out: PROC_UNLOCK(p); return (error); @@ -378,21 +375,20 @@ int thr_wake(struct thread *td, struct thr_wake_args *uap) /* long id */ { + struct proc *p; struct thread *ttd; - PROC_LOCK(td->td_proc); - FOREACH_THREAD_IN_PROC(td->td_proc, ttd) { - if (ttd->td_tid == uap->id) - break; - } + p = td->td_proc; + PROC_LOCK(p); + ttd = thread_find(p, uap->id); if (ttd == NULL) { - PROC_UNLOCK(td->td_proc); + PROC_UNLOCK(p); return (ESRCH); } mtx_lock_spin(&sched_lock); ttd->td_flags |= TDF_THRWAKEUP; mtx_unlock_spin(&sched_lock); wakeup((void *)ttd); - PROC_UNLOCK(td->td_proc); + PROC_UNLOCK(p); return (0); } |