about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-05-30 06:03:38 +0000
committerUlrich Drepper <drepper@redhat.com>2003-05-30 06:03:38 +0000
commit586d174837d85006bb64199f2ba15830f83ee28a (patch)
treedc296585dcf336f882c29caf6c7c6c8b1ab131d1 /nptl
parentb8ba4a2741c2d9e1b723615228bcacedb1b941c2 (diff)
downloadglibc-586d174837d85006bb64199f2ba15830f83ee28a.tar.gz
glibc-586d174837d85006bb64199f2ba15830f83ee28a.tar.xz
glibc-586d174837d85006bb64199f2ba15830f83ee28a.zip
Update.
	* Makefile (tests): Add tst-signal6.
	* tst-signal6.c: New file.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog3
-rw-r--r--nptl/Makefile1
-rw-r--r--nptl/TODO-kernel13
-rw-r--r--nptl/tst-signal6.c192
4 files changed, 200 insertions, 9 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 5b7d306869..eb56d05a9e 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,5 +1,8 @@
 2003-05-29  Ulrich Drepper  <drepper@redhat.com>
 
+	* Makefile (tests): Add tst-signal6.
+	* tst-signal6.c: New file.
+
 	* sysdeps/unix/sysv/linux/s390/lowlevellock.h
 	(__lll_mutex_unlock_force): New function
 	(lll_mutex_unlock_force): Use __lll_mutex_unlock_force.
diff --git a/nptl/Makefile b/nptl/Makefile
index 31faa7c4a8..5af2f4331a 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -167,6 +167,7 @@ tests = tst-attr1 tst-attr2 \
 	tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \
 	tst-flock1 tst-flock2 \
 	tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
+	tst-signal6 \
 	tst-exec1 tst-exec2 tst-exec3 \
 	tst-exit1 \
 	tst-stdio1 tst-stdio2 \
diff --git a/nptl/TODO-kernel b/nptl/TODO-kernel
index 3ef4a3924d..7c16f8e1a4 100644
--- a/nptl/TODO-kernel
+++ b/nptl/TODO-kernel
@@ -8,20 +8,15 @@
 
 - nice level is process property
 
-- getppid(() must return process ID of parent process of the thread
-  group leader
-  + test core file content (psinfo, prstatus)
-    The question is: do we really want this?  The "wrong" information
-    actually provides some information one cannot get easily otherwise.
-
 - rlimit should be process-wide and SIGXCPU should be sent if all threads
   together exceed the limit
 
 - getrusage() must return resource utilization for the process
 
-- sigaltstack must be per-thread (???)
 
-   I've an interpretation request outstanding
 
-- the scheduler must be thread group-aware, i.e., it has to give time to
+The following are possible optimizations and in no way required:
+
+
+- the scheduler should be thread group-aware, i.e., it has to give time to
   the thread group not proportional to the number of threads.
diff --git a/nptl/tst-signal6.c b/nptl/tst-signal6.c
new file mode 100644
index 0000000000..85a8640027
--- /dev/null
+++ b/nptl/tst-signal6.c
@@ -0,0 +1,192 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#define N 2
+static pthread_barrier_t bar;
+static struct
+{
+  void *p;
+  pthread_t s;
+} ti[N];
+static int sig1;
+
+
+static void
+handler (int sig)
+{
+  pthread_t self = pthread_self ();
+  size_t i;
+
+  for (i = 0; i < N; ++i)
+    if (ti[i].s == self)
+      {
+	if ((uintptr_t) ti[i].p <= (uintptr_t) &self
+	    && (uintptr_t) ti[i].p + 2 * MINSIGSTKSZ > (uintptr_t) &self)
+	  {
+	    puts ("alt stack not used");
+	    exit (1);
+	  }
+
+	printf ("thread %zu used alt stack for signal %d\n", i, sig);
+
+	return;
+      }
+
+  puts ("handler: thread not found");
+  exit (1);
+}
+
+
+static void *
+tf (void *arg)
+{
+  size_t nr = (uintptr_t) arg;
+  if (nr >= N)
+    {
+      puts ("wrong nr parameter");
+      exit (1);
+    }
+
+  sigset_t ss;
+  sigemptyset (&ss);
+  size_t i;
+  for (i = 0; i < N; ++i)
+    if (i != nr)
+      if (sigaddset (&ss, sig1 + i) != 0)
+	{
+	  puts ("tf: sigaddset failed");
+	  exit (1);
+	}
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("tf: sigmask failed");
+      exit (1);
+    }
+
+  void *p = malloc (2 * MINSIGSTKSZ);
+  if (p == NULL)
+    {
+      puts ("tf: malloc failed");
+      exit (1);
+    }
+
+  stack_t s;
+  s.ss_sp = p;
+  s.ss_size = 2 * MINSIGSTKSZ;
+  s.ss_flags = 0;
+  if (sigaltstack (&s, NULL) != 0)
+    {
+      puts ("tf: sigaltstack failed");
+      exit (1);
+    }
+
+  ti[nr].p = p;
+  ti[nr].s = pthread_self ();
+
+  pthread_barrier_wait (&bar);
+
+  pthread_barrier_wait (&bar);
+
+  return NULL;
+}
+
+
+static int
+do_test (void)
+{
+  sig1 = SIGRTMIN;
+  if (sig1 + N > SIGRTMAX)
+    {
+      puts ("too few RT signals");
+      return 0;
+    }
+
+  struct sigaction sa;
+  sa.sa_handler = handler;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  if (sigaction (sig1, &sa, NULL) != 0
+      || sigaction (sig1 + 1, &sa, NULL) != 0
+      || sigaction (sig1 + 2, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&bar, NULL, 1 + N) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
+  pthread_t th[N];
+  size_t i;
+  for (i = 0; i < N; ++i)
+    if (pthread_create (&th[i], NULL, tf, (void *) (long int) i) != 0)
+      {
+	puts ("create failed");
+	return 1;
+      }
+
+  /* Block the three signals.  */
+  sigset_t ss;
+  sigemptyset (&ss);
+  for (i = 0; i <= N; ++i)
+    sigaddset (&ss, sig1 + i);
+  if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+    {
+      puts ("main: sigmask failed");
+      return 1;
+    }
+
+  pthread_barrier_wait (&bar);
+
+  /* Send some signals.  */
+  pid_t me = getpid ();
+  kill (me, sig1 + N);
+  for (i = 0; i < N; ++i)
+    kill (me, sig1 + i);
+  kill (me, sig1 + N);
+
+  /* Give the signals a chance to be worked on.  */
+  sleep (1);
+
+  pthread_barrier_wait (&bar);
+
+  for (i = 0; i < N; ++i)
+    if (pthread_join (th[i], NULL) != 0)
+      {
+	puts ("join failed");
+	return 1;
+      }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"