diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-02-14 23:31:11 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-02-14 23:31:11 +0000 |
commit | 472022708ee08ac559dde540891eb2f8c2a9afcf (patch) | |
tree | f30a25b8039eab48c7b6e2737a5f856bdb853b78 /nptl/pthread_create.c | |
parent | e320ef46a7283517aeba1decc20ffb38ed131281 (diff) | |
download | glibc-472022708ee08ac559dde540891eb2f8c2a9afcf.tar.gz glibc-472022708ee08ac559dde540891eb2f8c2a9afcf.tar.xz glibc-472022708ee08ac559dde540891eb2f8c2a9afcf.zip |
Update.
2003-02-14 Ulrich Drepper <drepper@redhat.com> * sysdeps/generic/libc-start.c [HAVE_PTR_NTHREADS]: Decrement thread counter and only call __exit_thread if this is not the last thread.
Diffstat (limited to 'nptl/pthread_create.c')
-rw-r--r-- | nptl/pthread_create.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 2b33243cee..c96a2813e5 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -44,6 +44,9 @@ static td_thr_events_t __nptl_threads_events; /* Pointer to descriptor with the last event. */ static struct pthread *__nptl_last_event; +/* Number of threads running. */ +unsigned int __nptl_nthreads = 1; + /* Code to allocate and deallocate a stack. */ #define DEFINE_DEALLOC @@ -197,6 +200,9 @@ __free_tcb (struct pthread *pd) static int start_thread (void *arg) { + /* One more thread. */ + atomic_increment (&__nptl_nthreads); + struct pthread *pd = (struct pthread *) arg; #if HP_TIMING_AVAIL @@ -215,6 +221,14 @@ start_thread (void *arg) } + /* If this is the last thread we terminate the process now. We + do not notify the debugger, it might just irritate it if there + is no thread left. */ + if (atomic_decrement_and_test (&__nptl_nthreads)) + /* This was the last thread. */ + exit (0); + + /* Report the death of the thread if this is wanted. */ if (__builtin_expect (pd->report_events, 0)) { |