about summary refs log tree commit diff
path: root/linuxthreads
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog4
-rw-r--r--linuxthreads/Examples/ex17.c17
-rw-r--r--linuxthreads/tst-context.c6
3 files changed, 27 insertions, 0 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index d38b8a7cf9..b4c51749ef 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,7 @@
+2001-07-31  Ulrich Drepper  <drepper@redhat.com>
+
+	* Examples/ex17.c: Make sure test thread is around long enough.
+
 2001-07-26  kaz Kojima  <kkojima@rr.iij4u.or.jp>
 
 	* sysdeps/sh/pt-machine.h (THREAD_SELF, INIT_THREAD_SELF): Defined.
diff --git a/linuxthreads/Examples/ex17.c b/linuxthreads/Examples/ex17.c
index f5c99ee3fb..a3ab909990 100644
--- a/linuxthreads/Examples/ex17.c
+++ b/linuxthreads/Examples/ex17.c
@@ -6,9 +6,12 @@
 #include <limits.h>
 #include <sys/mman.h>
 
+static pthread_mutex_t synch = PTHREAD_MUTEX_INITIALIZER;
+
 static void *
 test_thread (void *v_param)
 {
+  pthread_mutex_lock (&synch);
   return NULL;
 }
 
@@ -56,6 +59,13 @@ main (void)
       return 2;
     }
 
+  status = pthread_mutex_lock (&synch);
+  if (status != 0)
+    {
+      printf ("cannot get lock: %s\n", strerror (status));
+      return 1;
+    }
+
   status = pthread_create (&thread, &attr, test_thread, NULL);
   if (status != 0)
     {
@@ -85,6 +95,13 @@ main (void)
       return 3;
     }
 
+  status = pthread_mutex_unlock (&synch);
+  if (status != 0)
+    {
+      printf ("cannot release lock: %s\n", strerror (status));
+      return 1;
+    }
+
   /* pthread_detach (thread); */
   if (pthread_join (thread, NULL) != 0)
     {
diff --git a/linuxthreads/tst-context.c b/linuxthreads/tst-context.c
index 82a877cffe..c72b2ac101 100644
--- a/linuxthreads/tst-context.c
+++ b/linuxthreads/tst-context.c
@@ -28,6 +28,12 @@ threadfct (void *arg)
 {
   int n = (int) (long int) arg;
 
+  if (getcontext (&ctx[n][1]) != 0)
+    {
+      printf ("%d: cannot get context: %m\n", n);
+      exit (1);
+    }
+
   printf ("%d: %s: before makecontext\n", n, __FUNCTION__);
 
   ctx[n][1].uc_stack.ss_sp = stacks[n];