diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_thread.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 89f6137..40652b6 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -981,7 +981,12 @@ void tidhash_add(struct thread *td) { rw_wlock(&tidhash_lock); - LIST_INSERT_HEAD(TIDHASH(td->td_tid), td, td_hash); + thread_lock(td); + if ((td->td_flags & TDF_TIDHASH) == 0) { + LIST_INSERT_HEAD(TIDHASH(td->td_tid), td, td_hash); + td->td_flags |= TDF_TIDHASH; + } + thread_unlock(td); rw_wunlock(&tidhash_lock); } @@ -989,6 +994,11 @@ void tidhash_remove(struct thread *td) { rw_wlock(&tidhash_lock); - LIST_REMOVE(td, td_hash); + thread_lock(td); + if ((td->td_flags & TDF_TIDHASH) != 0) { + LIST_REMOVE(td, td_hash); + td->td_flags &= ~TDF_TIDHASH; + } + thread_unlock(td); rw_wunlock(&tidhash_lock); } |