summaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-11-10 09:02:52 +0000
committerJakub Jelinek <jakub@redhat.com>2004-11-10 09:02:52 +0000
commit3504bb650f48534549bbd0313dc15fa71455e302 (patch)
tree742dd9cbcee1147fb36bcc02816bec415544597e /nptl
parentcbf4bcd2b3d53de274548dbf4c28017d1f07d5b2 (diff)
Updated to fedora-glibc-20041110T0839
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog25
-rw-r--r--nptl/Makefile2
-rw-r--r--nptl/pthread_create.c3
-rw-r--r--nptl/sysdeps/pthread/createthread.c12
-rw-r--r--nptl/tst-exit2.c40
-rw-r--r--nptl/tst-exit3.c81
6 files changed, 159 insertions, 4 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 31be4c37bb..98df5cf228 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,28 @@
+2004-11-10 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-exit3.
+ * tst-exit3.c: New test.
+
+2004-11-09 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-exit2.
+ * tst-exit2.c: New file.
+
+2004-11-09 Roland McGrath <roland@redhat.com>
+
+ [BZ #530]
+ * sysdeps/pthread/createthread.c (do_clone): Increment __nptl_nthreads
+ here, before calling clone.
+ * pthread_create.c (start_thread): Don't do it here.
+
+2004-11-04 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_getcpuclockid.c: New file.
+
+2004-11-02 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/smp.h: Include <errno.h>.
+
2004-10-29 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sem_timedwait.S (sem_timedwait):
diff --git a/nptl/Makefile b/nptl/Makefile
index f39e0bd303..564eaca6c5 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -227,7 +227,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
tst-signal6 \
tst-exec1 tst-exec2 tst-exec3 tst-exec4 \
- tst-exit1 \
+ tst-exit1 tst-exit2 tst-exit3 \
tst-stdio1 tst-stdio2 \
tst-stack1 tst-stack2 tst-stack3 \
tst-unload \
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 7293f4c71c..82a3c683aa 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -222,9 +222,6 @@ __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
diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c
index 8620519887..25a2703ae1 100644
--- a/nptl/sysdeps/pthread/createthread.c
+++ b/nptl/sysdeps/pthread/createthread.c
@@ -64,9 +64,21 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr,
until we tell it to. */
lll_lock (pd->lock);
+ /* One more thread. We cannot have the thread do this itself, since it
+ might exist but not have been scheduled yet by the time we've returned
+ and need to check the value to behave correctly. We must do it before
+ creating the thread, in case it does get scheduled first and then
+ might mistakenly think it was the only thread. In the failure case,
+ we momentarily store a false value; this doesn't matter because there
+ is no kosher thing a signal handler interrupting us right here can do
+ that cares whether the thread count is correct. */
+ atomic_increment (&__nptl_nthreads);
+
if (ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags,
pd, &pd->tid, TLS_VALUE, &pd->tid) == -1)
{
+ atomic_decrement (&__nptl_nthreads); /* Oops, we lied for a second. */
+
/* Failed. If the thread is detached, remove the TCB here since
the caller cannot do this. The caller remembered the thread
as detached and cannot reverify that it is not since it must
diff --git a/nptl/tst-exit2.c b/nptl/tst-exit2.c
new file mode 100644
index 0000000000..3f5ff27b0f
--- /dev/null
+++ b/nptl/tst-exit2.c
@@ -0,0 +1,40 @@
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+ while (1)
+ sleep (100);
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ int e = pthread_create (&th, NULL, tf, NULL);
+ if (e != 0)
+ {
+ printf ("create failed: %s\n", strerror (e));
+ return 1;
+ }
+
+ /* Terminate only this thread. */
+ pthread_exit (NULL);
+
+ /* NOTREACHED */
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-exit3.c b/nptl/tst-exit3.c
new file mode 100644
index 0000000000..da92c82c0e
--- /dev/null
+++ b/nptl/tst-exit3.c
@@ -0,0 +1,81 @@
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+static void *
+tf2 (void *arg)
+{
+ while (1)
+ sleep (100);
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_t th;
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ e = pthread_create (&th, NULL, tf2, NULL);
+ if (e != 0)
+ {
+ printf ("create failed: %s\n", strerror (e));
+ exit (1);
+ }
+
+ /* Terminate only this thread. */
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ int e = pthread_create (&th, NULL, tf, NULL);
+ if (e != 0)
+ {
+ printf ("create failed: %s\n", strerror (e));
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ /* Terminate only this thread. */
+ pthread_exit (NULL);
+
+ /* NOTREACHED */
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"