diff options
author | jasone <jasone@FreeBSD.org> | 1999-07-11 05:56:37 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 1999-07-11 05:56:37 +0000 |
commit | d1e30ddcd16d4d7217ba77db099fe1c9bbe85803 (patch) | |
tree | 3908ace46508aeb3c84794ab51e089a5ab6a9050 /lib/libpthread/thread/thr_gc.c | |
parent | f687757a7c174d7f844f10cb815bdcc00a2632ff (diff) | |
download | FreeBSD-src-d1e30ddcd16d4d7217ba77db099fe1c9bbe85803.zip FreeBSD-src-d1e30ddcd16d4d7217ba77db099fe1c9bbe85803.tar.gz |
Modify previous changes to conform better to libc_r's coding style.
Always use mmap() for default-size stack allocation. Use MAP_ANON instead
of MAP_STACK on the alpha architecture.
Reduce the amount of code executed while owning _gc_mutex during stack
allocation.
Diffstat (limited to 'lib/libpthread/thread/thr_gc.c')
-rw-r--r-- | lib/libpthread/thread/thr_gc.c | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/lib/libpthread/thread/thr_gc.c b/lib/libpthread/thread/thr_gc.c index 6b504d9..cb8de13 100644 --- a/lib/libpthread/thread/thr_gc.c +++ b/lib/libpthread/thread/thr_gc.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: uthread_gc.c,v 1.5 1999/07/05 00:35:18 jasone Exp $ + * $Id: uthread_gc.c,v 1.6 1999/07/06 00:25:37 jasone Exp $ * * Garbage collector thread. Frees memory allocated for dead threads. * @@ -113,8 +113,8 @@ _thread_gc(pthread_addr_t arg) * has memory to free. */ for (pthread = TAILQ_FIRST(&_dead_list); - p_stack == NULL && pthread_cln == NULL && pthread != NULL; - pthread = TAILQ_NEXT(pthread, dle)) { + p_stack == NULL && pthread_cln == NULL && pthread != NULL; + pthread = TAILQ_NEXT(pthread, dle)) { /* Check if the initial thread: */ if (pthread == _thread_initial) { /* Don't destroy the initial thread. */ @@ -123,7 +123,7 @@ _thread_gc(pthread_addr_t arg) * Check if this thread has detached: */ else if ((pthread->attr.flags & - PTHREAD_DETACHED) != 0) { + PTHREAD_DETACHED) != 0) { /* Remove this thread from the dead list: */ TAILQ_REMOVE(&_dead_list, pthread, dle); @@ -134,23 +134,28 @@ _thread_gc(pthread_addr_t arg) */ if (pthread->attr.stackaddr_attr == NULL && pthread->stack != NULL) { -#ifdef __i386__ - if (pthread->attr.stacksize_attr == PTHREAD_STACK_DEFAULT) { - /* Default-size stack. Cache it: */ - struct stack * spare_stack = (pthread->stack + PTHREAD_STACK_DEFAULT - - sizeof(struct stack)); - SLIST_INSERT_HEAD(&_stackq, spare_stack, qe); + if (pthread->attr.stacksize_attr + == PTHREAD_STACK_DEFAULT) { + /* + * Default-size stack. Cache + * it: + */ + struct stack * spare_stack; + + spare_stack + = (pthread->stack + + PTHREAD_STACK_DEFAULT + - sizeof(struct stack)); + SLIST_INSERT_HEAD(&_stackq, + spare_stack, + qe); } else { - /* Non-standard stack size. free() it outside the locks: */ + /* + * Non-standard stack size. + * free() it outside the locks. + */ p_stack = pthread->stack; } -#else - /* - * Point to the stack that must - * be freed outside the locks: - */ - p_stack = pthread->stack; -#endif } /* @@ -170,23 +175,28 @@ _thread_gc(pthread_addr_t arg) */ if (pthread->attr.stackaddr_attr == NULL && pthread->stack != NULL) { -#ifdef __i386__ - if (pthread->attr.stacksize_attr == PTHREAD_STACK_DEFAULT) { - /* Default-size stack. Cache it: */ - struct stack * spare_stack = (pthread->stack + PTHREAD_STACK_DEFAULT - - sizeof(struct stack)); - SLIST_INSERT_HEAD(&_stackq, spare_stack, qe); + if (pthread->attr.stacksize_attr + == PTHREAD_STACK_DEFAULT) { + /* + * Default-size stack. Cache + * it: + */ + struct stack * spare_stack; + + spare_stack + = (pthread->stack + + PTHREAD_STACK_DEFAULT + - sizeof(struct stack)); + SLIST_INSERT_HEAD(&_stackq, + spare_stack, + qe); } else { - /* Non-standard stack size. free() it outside the locks: */ + /* + * Non-standard stack size. + * free() it outside the locks: + */ p_stack = pthread->stack; } -#else - /* - * Point to the stack that must - * be freed outside the locks: - */ - p_stack = pthread->stack; -#endif /* * NULL the stack pointer now |