From 56b39ee1c2097e81279c32b2d5d53045a13cf025 Mon Sep 17 00:00:00 2001 From: David Xu Date: Sat, 16 Aug 2003 05:22:20 +0000 Subject: Keep initial kse and kse group just like we keep initial thread, Don't free them, so some code can still reference them. Reviewed by: deischen --- lib/libpthread/thread/thr_kern.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/libpthread/thread') diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index c78a28ac7a94..ae151d7b9a84 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -1336,6 +1336,15 @@ thread_gc(struct pthread *curthread) while ((td = TAILQ_FIRST(&worklist)) != NULL) { TAILQ_REMOVE(&worklist, td, gcle); + /* + * XXX we don't free initial thread and its kse + * (if thread is a bound thread), because there might + * have some code referencing initial thread and kse. + */ + if (td == _thr_initial) { + DBG_MSG("Initial thread won't be freed\n"); + continue; + } if ((td->attr.flags & PTHREAD_SCOPE_SYSTEM) != 0) { crit = _kse_critical_enter(); @@ -1345,15 +1354,8 @@ thread_gc(struct pthread *curthread) KSE_LOCK_RELEASE(curthread->kse, &kse_lock); _kse_critical_leave(crit); } - /* - * XXX we don't free initial thread, because there might - * have some code referencing initial thread. - */ - if (td != _thr_initial) { - DBG_MSG("Freeing thread %p\n", td); - _thr_free(curthread, td); - } else - DBG_MSG("Initial thread won't be freed\n"); + DBG_MSG("Freeing thread %p\n", td); + _thr_free(curthread, td); } } -- cgit v1.2.3