change log for rtems (2011-07-31)

rtems-vc at rtems.org rtems-vc at rtems.org
Sun Jul 31 23:11:03 UTC 2011


 *joel*:
2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>

	PR 1855/cpukit
	* posix/src/psignal.c, posix/src/pthread.c, posix/src/pthreadjoin.c:
	Correct signal processing during pthread_join. We are supposed to
	unblock the thread waiting on a pthread_join(), dispatch the signal
	handler, account for it potentially overwriting errno, and then have
	the thread return to blocking within pthread_join().

M 1.2893  cpukit/ChangeLog
M   1.71  cpukit/posix/src/psignal.c
M   1.85  cpukit/posix/src/pthread.c
M   1.13  cpukit/posix/src/pthreadjoin.c

diff -u rtems/cpukit/ChangeLog:1.2892 rtems/cpukit/ChangeLog:1.2893
--- rtems/cpukit/ChangeLog:1.2892	Sun Jul 31 11:15:59 2011
+++ rtems/cpukit/ChangeLog	Sun Jul 31 17:40:22 2011
@@ -1,5 +1,14 @@
 2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
+	PR 1855/cpukit
+	* posix/src/psignal.c, posix/src/pthread.c, posix/src/pthreadjoin.c:
+	Correct signal processing during pthread_join. We are supposed to
+	unblock the thread waiting on a pthread_join(), dispatch the signal
+	handler, account for it potentially overwriting errno, and then have
+	the thread return to blocking within pthread_join().
+
+2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
+
 	PR 1867/cpukit
 	* posix/src/pthreadexit.c, posix/src/pthreadjoin.c: Correct
 	implementation of pthread_exit() and pthread_join() to support the

diff -u rtems/cpukit/posix/src/psignal.c:1.70 rtems/cpukit/posix/src/psignal.c:1.71
--- rtems/cpukit/posix/src/psignal.c:1.70	Sun Jul 24 18:55:08 2011
+++ rtems/cpukit/posix/src/psignal.c	Sun Jul 31 17:40:23 2011
@@ -112,10 +112,17 @@
   POSIX_API_Control  *api;
   int                 signo;
   ISR_Level           level;
+  int                 hold_errno;
 
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
   /*
+   *  We need to ensure that if the signal handler executes a call
+   *  which overwrites the unblocking status, we restore it.
+   */
+  hold_errno = _Thread_Executing->Wait.return_code;
+
+  /*
    * api may be NULL in case of a thread close in progress
    */
   if ( !api )
@@ -149,6 +156,8 @@
       _POSIX_signals_Check_signal( api, signo, true );
     }
   }
+
+  _Thread_Executing->Wait.return_code = hold_errno;
 }
 
 /*

diff -u rtems/cpukit/posix/src/pthread.c:1.84 rtems/cpukit/posix/src/pthread.c:1.85
--- rtems/cpukit/posix/src/pthread.c:1.84	Wed Jul 27 12:17:49 2011
+++ rtems/cpukit/posix/src/pthread.c	Sun Jul 31 17:40:23 2011
@@ -217,7 +217,7 @@
   _Thread_queue_Initialize(
     &api->Join_List,
     THREAD_QUEUE_DISCIPLINE_FIFO,
-    STATES_WAITING_FOR_JOIN_AT_EXIT,
+    STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
     0
   );
 

diff -u rtems/cpukit/posix/src/pthreadjoin.c:1.12 rtems/cpukit/posix/src/pthreadjoin.c:1.13
--- rtems/cpukit/posix/src/pthreadjoin.c:1.12	Sun Jul 31 11:16:00 2011
+++ rtems/cpukit/posix/src/pthreadjoin.c	Sun Jul 31 17:40:23 2011
@@ -1,7 +1,7 @@
 /*
  *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
  *
- *  COPYRIGHT (c) 1989-2007.
+ *  COPYRIGHT (c) 1989-2011.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -32,6 +32,7 @@
   Objects_Locations        location;
   void                    *return_pointer;
 
+on_EINTR:
   the_thread = _Thread_Get( thread, &location );
   switch ( location ) {
 
@@ -66,6 +67,9 @@
       }
       _Thread_Enable_dispatch();
 
+      if ( _Thread_Executing->Wait.return_code == EINTR )
+        goto on_EINTR;
+
       if ( value_ptr )
         *value_ptr = return_pointer;
       return 0;


 *joel*:
file .cvsignore was added on branch rtems-4-9-branch on 2011-07-31 22:41:17 +0000

R    1.1  testsuites/psxtests/psxeintr_join/.cvsignore

 *joel*:
file .cvsignore was added on branch rtems-4-10-branch on 2011-07-31 22:40:53 +0000

R    1.1  testsuites/psxtests/psxeintr_join/.cvsignore

 *joel*:
file psxeintr_join.doc was added on branch rtems-4-9-branch on 2011-07-31 22:41:17 +0000

R    1.1  testsuites/psxtests/psxeintr_join/psxeintr_join.doc

 *joel*:
file init.c was added on branch rtems-4-9-branch on 2011-07-31 22:41:17 +0000

R    1.1  testsuites/psxtests/psxeintr_join/init.c

 *joel*:
file Makefile.am was added on branch rtems-4-10-branch on 2011-07-31 22:40:53 +0000

R    1.1  testsuites/psxtests/psxeintr_join/Makefile.am

 *joel*:
file psxeintr_join.scn was added on branch rtems-4-9-branch on 2011-07-31 22:41:17 +0000

R    1.1  testsuites/psxtests/psxeintr_join/psxeintr_join.scn

 *joel*:
file psxeintr_join.doc was added on branch rtems-4-10-branch on 2011-07-31 22:40:53 +0000

R    1.1  testsuites/psxtests/psxeintr_join/psxeintr_join.doc

 *joel*:
branches:  1.1.2;  1.1.4;
2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>

	PR 1855/cpukit
	* Makefile.am, configure.ac: Correct signal processing during
	pthread_join. We are supposed to unblock the thread waiting on a
	pthread_join(), dispatch the signal handler, account for it
	potentially overwriting errno, and then have the thread return to
	blocking within pthread_join().
	* psxeintr_join/.cvsignore, psxeintr_join/Makefile.am,
	psxeintr_join/init.c, psxeintr_join/psxeintr_join.doc,
	psxeintr_join/psxeintr_join.scn: New files.

A    1.1  testsuites/psxtests/psxeintr_join/.cvsignore
A    1.1  testsuites/psxtests/psxeintr_join/Makefile.am
A    1.1  testsuites/psxtests/psxeintr_join/init.c
A    1.1  testsuites/psxtests/psxeintr_join/psxeintr_join.doc
A    1.1  testsuites/psxtests/psxeintr_join/psxeintr_join.scn

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/.cvsignore:1.1
--- /dev/null	Sun Jul 31 18:10:58 2011
+++ rtems/testsuites/psxtests/psxeintr_join/.cvsignore	Sun Jul 31 17:40:30 2011
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/Makefile.am:1.1
--- /dev/null	Sun Jul 31 18:10:58 2011
+++ rtems/testsuites/psxtests/psxeintr_join/Makefile.am	Sun Jul 31 17:40:31 2011
@@ -0,0 +1,25 @@
+##
+## $Id$
+##
+
+rtems_tests_PROGRAMS = psxeintr_join
+psxeintr_join_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxeintr_join.scn
+dist_rtems_tests_DATA += psxeintr_join.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxeintr_join_OBJECTS) $(psxeintr_join_LDADD)
+LINK_LIBS = $(psxeintr_join_LDLIBS)
+
+psxeintr_join$(EXEEXT): $(psxeintr_join_OBJECTS) $(psxeintr_join_DEPENDENCIES)
+	@rm -f psxeintr_join$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/init.c:1.1
--- /dev/null	Sun Jul 31 18:10:58 2011
+++ rtems/testsuites/psxtests/psxeintr_join/init.c	Sun Jul 31 17:40:31 2011
@@ -0,0 +1,125 @@
+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <pthread.h>
+
+#include <rtems.h>
+#include <tmacros.h>
+#include "test_support.h"
+
+#define SIG_SUSPEND SIGUSR1
+#define SIG_THR_RESTART SIGUSR2
+
+sem_t GC_suspend_ack_sem;
+
+static void print_sig_mask( const char * str )
+{
+  sigset_t blocked;
+  int      i;
+  int      status;
+
+  status = pthread_sigmask( SIG_BLOCK, NULL, &blocked );
+  rtems_test_assert( status == 0 );
+
+  printf( "%s blocked:\n", str );
+  for ( i = 1; i < NSIG; i++) {
+    if ( sigismember( &blocked, i ) )
+      printf( "%d ", i );
+  }
+  printf( "\n" );
+}
+
+void GC_suspend_handler( int sig )
+{
+  puts( "run in GC_suspend_handler" );
+  sem_post( &GC_suspend_ack_sem );
+}
+
+void GC_restart_handler( int sig )
+{
+  puts( "run in GC_restart_handler" );
+}
+
+void* run( void *arg )
+{
+  int       status;
+  pthread_t id = *(pthread_t *)arg;
+
+  print_sig_mask( "New Thread" );
+
+  status = pthread_kill( id, SIG_SUSPEND );
+  rtems_test_assert( status == 0 );
+
+  puts( "New Thread: after pthread_kill" );
+  status = sem_wait( &GC_suspend_ack_sem );
+  rtems_test_assert( status == 0 );
+
+  puts( "New Thread over!" );
+  return NULL;
+}
+
+void *POSIX_Init( void *arg )
+{
+  struct sigaction act;
+  pthread_t        newThread;
+  pthread_t        mainThread;
+  int              status;
+
+  puts( "*** POSIX TEST PSXEINTR_JOIN ***" );
+  status = sem_init( &GC_suspend_ack_sem, 0, 0);
+  rtems_test_assert( status == 0 );
+
+  status = sigemptyset( &act.sa_mask );
+  rtems_test_assert( status == 0 );
+
+  status = sigaddset( &act.sa_mask, SIG_SUSPEND );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_sigmask( SIG_UNBLOCK, &act.sa_mask, NULL );
+  rtems_test_assert( status == 0 );
+
+  act.sa_handler = GC_suspend_handler;
+
+  status = sigaction( SIG_SUSPEND, &act, NULL );
+  rtems_test_assert( status == 0 );
+
+  act.sa_handler = GC_restart_handler;
+
+  print_sig_mask( "Main Thread" );
+
+  mainThread = pthread_self();
+  status = pthread_create( &newThread, NULL, run, &mainThread );
+  rtems_test_assert( status == 0 );
+
+  pthread_join( newThread, NULL );
+  puts( "Back from pthread_join" );
+
+  puts( "*** END OF POSIX TEST PSXEINTR_JOIN ***" );
+  rtems_test_exit( 0 );
+
+  return NULL;
+}
+
+/* configuration information */
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
+

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.doc:1.1
--- /dev/null	Sun Jul 31 18:10:58 2011
+++ rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.doc	Sun Jul 31 17:40:31 2011
@@ -0,0 +1,24 @@
+#
+#  $Id$
+#
+#  COPYRIGHT (c) 1989-2011.
+#  On-Line Applications Research Corporation (OAR).
+#
+#  The license and distribution terms for this file may be
+#  found in the file LICENSE in this distribution or at
+#  http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name:  psxeintr_join
+
+directives:
+
+  + pthread_join
+  + pthread_kill
+
+concepts:
+
++ Verify that a signal sent during a blocking pthread_join() call is properly
+  processed.

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.scn:1.1
--- /dev/null	Sun Jul 31 18:10:58 2011
+++ rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.scn	Sun Jul 31 17:40:31 2011
@@ -0,0 +1,9 @@
+*** POSIX TEST PSXEINTR_JOIN ***
+Main Thread blocked: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 27 28 29 30 31 
+New Thread blocked: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 27 28 29 30 31 
+New Thread: after pthread_kill
+run in GC_suspend_handler
+New Thread over!
+Back from pthread_join
+*** END OF POSIX TEST PSXEINTR_JOIN ***
+


 *joel*:
file init.c was added on branch rtems-4-10-branch on 2011-07-31 22:40:53 +0000

R    1.1  testsuites/psxtests/psxeintr_join/init.c

 *joel*:
file psxeintr_join.scn was added on branch rtems-4-10-branch on 2011-07-31 22:40:53 +0000

R    1.1  testsuites/psxtests/psxeintr_join/psxeintr_join.scn

 *joel*:
file Makefile.am was added on branch rtems-4-9-branch on 2011-07-31 22:41:17 +0000

R    1.1  testsuites/psxtests/psxeintr_join/Makefile.am

 *joel* (on branch rtems-4-10-branch):
2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>

	PR 1855/cpukit
	* Makefile.am, configure.ac: Correct signal processing during
	pthread_join. We are supposed to unblock the thread waiting on a
	pthread_join(), dispatch the signal handler, account for it
	potentially overwriting errno, and then have the thread return to
	blocking within pthread_join().
	* psxeintr_join/.cvsignore, psxeintr_join/Makefile.am,
	psxeintr_join/init.c, psxeintr_join/psxeintr_join.doc,
	psxeintr_join/psxeintr_join.scn: New files.

M  1.349  testsuites/psxtests/ChangeLog
M 1.264.2.5  testsuites/psxtests/ChangeLog
M   1.77  testsuites/psxtests/Makefile.am
M 1.58.2.2  testsuites/psxtests/Makefile.am
M   1.85  testsuites/psxtests/configure.ac
M 1.61.2.5  testsuites/psxtests/configure.ac
M 1.1.2.2  testsuites/psxtests/psxeintr_join/.cvsignore
M 1.1.2.2  testsuites/psxtests/psxeintr_join/Makefile.am
M 1.1.2.2  testsuites/psxtests/psxeintr_join/init.c
M 1.1.2.2  testsuites/psxtests/psxeintr_join/psxeintr_join.doc
M 1.1.2.2  testsuites/psxtests/psxeintr_join/psxeintr_join.scn

diff -u rtems/testsuites/psxtests/ChangeLog:1.348 rtems/testsuites/psxtests/ChangeLog:1.349
--- rtems/testsuites/psxtests/ChangeLog:1.348	Sun Jul 31 11:16:17 2011
+++ rtems/testsuites/psxtests/ChangeLog	Sun Jul 31 17:40:30 2011
@@ -1,5 +1,17 @@
 2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
+	PR 1855/cpukit
+	* Makefile.am, configure.ac: Correct signal processing during
+	pthread_join. We are supposed to unblock the thread waiting on a
+	pthread_join(), dispatch the signal handler, account for it
+	potentially overwriting errno, and then have the thread return to
+	blocking within pthread_join().
+	* psxeintr_join/.cvsignore, psxeintr_join/Makefile.am,
+	psxeintr_join/init.c, psxeintr_join/psxeintr_join.doc,
+	psxeintr_join/psxeintr_join.scn: New files.
+
+2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
+
 	PR 1867/cpukit
 	* Makefile.am, configure.ac, psx12/task.c, psxkey03/init.c,
 	psxrwlock01/test.c: Correct implementation of pthread_exit() and

diff -u rtems/testsuites/psxtests/ChangeLog:1.264.2.4 rtems/testsuites/psxtests/ChangeLog:1.264.2.5
--- rtems/testsuites/psxtests/ChangeLog:1.264.2.4	Sun Jul 31 11:16:42 2011
+++ rtems/testsuites/psxtests/ChangeLog	Sun Jul 31 17:40:53 2011
@@ -1,5 +1,17 @@
 2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
+	PR 1855/cpukit
+	* Makefile.am, configure.ac: Correct signal processing during
+	pthread_join. We are supposed to unblock the thread waiting on a
+	pthread_join(), dispatch the signal handler, account for it
+	potentially overwriting errno, and then have the thread return to
+	blocking within pthread_join().
+	* psxeintr_join/.cvsignore, psxeintr_join/Makefile.am,
+	psxeintr_join/init.c, psxeintr_join/psxeintr_join.doc,
+	psxeintr_join/psxeintr_join.scn: New files.
+
+2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
+
 	PR 1867/cpukit
 	* Makefile.am, configure.ac, psx12/task.c, psxkey03/init.c,
 	psxrwlock01/test.c: Correct implementation of pthread_exit() and

diff -u rtems/testsuites/psxtests/Makefile.am:1.76 rtems/testsuites/psxtests/Makefile.am:1.77
--- rtems/testsuites/psxtests/Makefile.am:1.76	Sun Jul 31 11:16:17 2011
+++ rtems/testsuites/psxtests/Makefile.am	Sun Jul 31 17:40:30 2011
@@ -17,7 +17,8 @@
     psxsignal03 psxsignal04 psxsignal05 psxsignal06 \
     psxspin01 psxspin02 psxsysconf \
     psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
-    psxintrcritical01 psxstack01 psxstack02
+    psxintrcritical01 psxstack01 psxstack02 \
+    psxeintr_join
 endif
 
 ## File IO tests

diff -u rtems/testsuites/psxtests/Makefile.am:1.58.2.1 rtems/testsuites/psxtests/Makefile.am:1.58.2.2
--- rtems/testsuites/psxtests/Makefile.am:1.58.2.1	Sun Jul 31 11:16:43 2011
+++ rtems/testsuites/psxtests/Makefile.am	Sun Jul 31 17:40:53 2011
@@ -15,7 +15,7 @@
     psxmutexattr01 psxobj01 psxrwlock01 psxsem01 psxsignal01 psxsignal02 \
     psxsignal03 psxsignal04 psxsignal05 psxspin01 psxspin02 psxsysconf \
     psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
-    psxintrcritical01 psxstack01
+    psxintrcritical01 psxstack01 psxeintr_join
 endif
 
 ## File IO tests

diff -u rtems/testsuites/psxtests/configure.ac:1.84 rtems/testsuites/psxtests/configure.ac:1.85
--- rtems/testsuites/psxtests/configure.ac:1.84	Sun Jul 31 11:16:17 2011
+++ rtems/testsuites/psxtests/configure.ac	Sun Jul 31 17:40:30 2011
@@ -112,6 +112,7 @@
 psxcleanup01/Makefile
 psxclock/Makefile
 psxcond01/Makefile
+psxeintr_join/Makefile
 psxenosys/Makefile
 psxfatal01/Makefile
 psxfatal02/Makefile

diff -u rtems/testsuites/psxtests/configure.ac:1.61.2.4 rtems/testsuites/psxtests/configure.ac:1.61.2.5
--- rtems/testsuites/psxtests/configure.ac:1.61.2.4	Sun Jul 31 11:16:43 2011
+++ rtems/testsuites/psxtests/configure.ac	Sun Jul 31 17:40:53 2011
@@ -86,6 +86,7 @@
 psxcleanup01/Makefile
 psxclock/Makefile
 psxcond01/Makefile
+psxeintr_join/Makefile
 psxenosys/Makefile
 psxfatal01/Makefile
 psxfatal02/Makefile

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/.cvsignore:1.1.2.2
--- /dev/null	Sun Jul 31 18:10:59 2011
+++ rtems/testsuites/psxtests/psxeintr_join/.cvsignore	Sun Jul 31 17:40:53 2011
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/Makefile.am:1.1.2.2
--- /dev/null	Sun Jul 31 18:10:59 2011
+++ rtems/testsuites/psxtests/psxeintr_join/Makefile.am	Sun Jul 31 17:40:53 2011
@@ -0,0 +1,25 @@
+##
+## $Id$
+##
+
+rtems_tests_PROGRAMS = psxeintr_join
+psxeintr_join_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxeintr_join.scn
+dist_rtems_tests_DATA += psxeintr_join.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxeintr_join_OBJECTS) $(psxeintr_join_LDADD)
+LINK_LIBS = $(psxeintr_join_LDLIBS)
+
+psxeintr_join$(EXEEXT): $(psxeintr_join_OBJECTS) $(psxeintr_join_DEPENDENCIES)
+	@rm -f psxeintr_join$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/init.c:1.1.2.2
--- /dev/null	Sun Jul 31 18:10:59 2011
+++ rtems/testsuites/psxtests/psxeintr_join/init.c	Sun Jul 31 17:40:53 2011
@@ -0,0 +1,125 @@
+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <pthread.h>
+
+#include <rtems.h>
+#include <tmacros.h>
+#include "test_support.h"
+
+#define SIG_SUSPEND SIGUSR1
+#define SIG_THR_RESTART SIGUSR2
+
+sem_t GC_suspend_ack_sem;
+
+static void print_sig_mask( const char * str )
+{
+  sigset_t blocked;
+  int      i;
+  int      status;
+
+  status = pthread_sigmask( SIG_BLOCK, NULL, &blocked );
+  rtems_test_assert( status == 0 );
+
+  printf( "%s blocked:\n", str );
+  for ( i = 1; i < NSIG; i++) {
+    if ( sigismember( &blocked, i ) )
+      printf( "%d ", i );
+  }
+  printf( "\n" );
+}
+
+void GC_suspend_handler( int sig )
+{
+  puts( "run in GC_suspend_handler" );
+  sem_post( &GC_suspend_ack_sem );
+}
+
+void GC_restart_handler( int sig )
+{
+  puts( "run in GC_restart_handler" );
+}
+
+void* run( void *arg )
+{
+  int       status;
+  pthread_t id = *(pthread_t *)arg;
+
+  print_sig_mask( "New Thread" );
+
+  status = pthread_kill( id, SIG_SUSPEND );
+  rtems_test_assert( status == 0 );
+
+  puts( "New Thread: after pthread_kill" );
+  status = sem_wait( &GC_suspend_ack_sem );
+  rtems_test_assert( status == 0 );
+
+  puts( "New Thread over!" );
+  return NULL;
+}
+
+void *POSIX_Init( void *arg )
+{
+  struct sigaction act;
+  pthread_t        newThread;
+  pthread_t        mainThread;
+  int              status;
+
+  puts( "*** POSIX TEST PSXEINTR_JOIN ***" );
+  status = sem_init( &GC_suspend_ack_sem, 0, 0);
+  rtems_test_assert( status == 0 );
+
+  status = sigemptyset( &act.sa_mask );
+  rtems_test_assert( status == 0 );
+
+  status = sigaddset( &act.sa_mask, SIG_SUSPEND );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_sigmask( SIG_UNBLOCK, &act.sa_mask, NULL );
+  rtems_test_assert( status == 0 );
+
+  act.sa_handler = GC_suspend_handler;
+
+  status = sigaction( SIG_SUSPEND, &act, NULL );
+  rtems_test_assert( status == 0 );
+
+  act.sa_handler = GC_restart_handler;
+
+  print_sig_mask( "Main Thread" );
+
+  mainThread = pthread_self();
+  status = pthread_create( &newThread, NULL, run, &mainThread );
+  rtems_test_assert( status == 0 );
+
+  pthread_join( newThread, NULL );
+  puts( "Back from pthread_join" );
+
+  puts( "*** END OF POSIX TEST PSXEINTR_JOIN ***" );
+  rtems_test_exit( 0 );
+
+  return NULL;
+}
+
+/* configuration information */
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
+

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.doc:1.1.2.2
--- /dev/null	Sun Jul 31 18:10:59 2011
+++ rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.doc	Sun Jul 31 17:40:53 2011
@@ -0,0 +1,24 @@
+#
+#  $Id$
+#
+#  COPYRIGHT (c) 1989-2011.
+#  On-Line Applications Research Corporation (OAR).
+#
+#  The license and distribution terms for this file may be
+#  found in the file LICENSE in this distribution or at
+#  http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name:  psxeintr_join
+
+directives:
+
+  + pthread_join
+  + pthread_kill
+
+concepts:
+
++ Verify that a signal sent during a blocking pthread_join() call is properly
+  processed.

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.scn:1.1.2.2
--- /dev/null	Sun Jul 31 18:10:59 2011
+++ rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.scn	Sun Jul 31 17:40:53 2011
@@ -0,0 +1,9 @@
+*** POSIX TEST PSXEINTR_JOIN ***
+Main Thread blocked: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 27 28 29 30 31 
+New Thread blocked: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 27 28 29 30 31 
+New Thread: after pthread_kill
+run in GC_suspend_handler
+New Thread over!
+Back from pthread_join
+*** END OF POSIX TEST PSXEINTR_JOIN ***
+


 *joel* (on branch rtems-4-9-branch):
2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>

	PR 1855/cpukit
	* posix/src/psignal.c, posix/src/psignalunblockthread.c,
	posix/src/pthread.c, posix/src/pthreadjoin.c: Correct signal
	processing during pthread_join. We are supposed to unblock the thread
	waiting on a pthread_join(), dispatch the signal handler, account for
	it potentially overwriting errno, and then have the thread return to
	blocking within pthread_join().

M 1.1539.2.80  cpukit/ChangeLog
M 1.2346.2.101  cpukit/ChangeLog
M 1.60.2.1  cpukit/posix/src/psignal.c
M 1.67.2.2  cpukit/posix/src/psignal.c
M 1.8.2.1  cpukit/posix/src/psignalunblockthread.c
M 1.10.2.1  cpukit/posix/src/psignalunblockthread.c
M 1.68.2.1  cpukit/posix/src/pthread.c
M 1.80.2.1  cpukit/posix/src/pthread.c
M 1.8.4.3  cpukit/posix/src/pthreadjoin.c
M 1.8.2.3  cpukit/posix/src/pthreadjoin.c

diff -u rtems/cpukit/ChangeLog:1.1539.2.79 rtems/cpukit/ChangeLog:1.1539.2.80
--- rtems/cpukit/ChangeLog:1.1539.2.79	Sun Jul 31 11:16:53 2011
+++ rtems/cpukit/ChangeLog	Sun Jul 31 17:41:04 2011
@@ -1,5 +1,15 @@
 2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
+	PR 1855/cpukit
+	* posix/src/psignal.c, posix/src/psignalunblockthread.c,
+	posix/src/pthread.c, posix/src/pthreadjoin.c: Correct signal
+	processing during pthread_join. We are supposed to unblock the thread
+	waiting on a pthread_join(), dispatch the signal handler, account for
+	it potentially overwriting errno, and then have the thread return to
+	blocking within pthread_join().
+
+2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
+
 	PR 1867/cpukit
 	* posix/src/pthreadexit.c, posix/src/pthreadjoin.c: Correct
 	implementation of pthread_exit() and pthread_join() to support the

diff -u rtems/cpukit/ChangeLog:1.2346.2.100 rtems/cpukit/ChangeLog:1.2346.2.101
--- rtems/cpukit/ChangeLog:1.2346.2.100	Sun Jul 31 11:16:28 2011
+++ rtems/cpukit/ChangeLog	Sun Jul 31 17:40:41 2011
@@ -1,5 +1,15 @@
 2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
+	PR 1855/cpukit
+	* posix/src/psignal.c, posix/src/psignalunblockthread.c,
+	posix/src/pthread.c, posix/src/pthreadjoin.c: Correct signal
+	processing during pthread_join. We are supposed to unblock the thread
+	waiting on a pthread_join(), dispatch the signal handler, account for
+	it potentially overwriting errno, and then have the thread return to
+	blocking within pthread_join().
+
+2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
+
 	PR 1867/cpukit
 	* posix/src/pthreadexit.c, posix/src/pthreadjoin.c: Correct
 	implementation of pthread_exit() and pthread_join() to support the

diff -u rtems/cpukit/posix/src/psignal.c:1.60 rtems/cpukit/posix/src/psignal.c:1.60.2.1
--- rtems/cpukit/posix/src/psignal.c:1.60	Thu Sep  4 10:23:12 2008
+++ rtems/cpukit/posix/src/psignal.c	Sun Jul 31 17:41:06 2011
@@ -1,5 +1,5 @@
 /*
- *  COPYRIGHT (c) 1989-2007.
+ *  COPYRIGHT (c) 1989-2011.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -106,6 +106,13 @@
   POSIX_API_Control  *api;
   int                 signo;
   ISR_Level           level;
+  int                 hold_errno;
+
+  /*
+   *  We need to ensure that if the signal handler executes a call
+   *  which overwrites the unblocking status, we restore it.
+   */
+  hold_errno = _Thread_Executing->Wait.return_code;
 
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
   if ( !api )

diff -u rtems/cpukit/posix/src/psignal.c:1.67.2.1 rtems/cpukit/posix/src/psignal.c:1.67.2.2
--- rtems/cpukit/posix/src/psignal.c:1.67.2.1	Fri Jan 21 13:31:34 2011
+++ rtems/cpukit/posix/src/psignal.c	Sun Jul 31 17:40:43 2011
@@ -113,10 +113,17 @@
   POSIX_API_Control  *api;
   int                 signo;
   ISR_Level           level;
+  int                 hold_errno;
 
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
   /*
+   *  We need to ensure that if the signal handler executes a call
+   *  which overwrites the unblocking status, we restore it.
+   */
+  hold_errno = _Thread_Executing->Wait.return_code;
+
+  /*
    * api may be NULL in case of a thread close in progress
    */
   if ( !api )
@@ -150,6 +157,8 @@
       _POSIX_signals_Check_signal( api, signo, true );
     }
   }
+
+  _Thread_Executing->Wait.return_code = hold_errno;
 }
 
 /*PAGE

diff -u rtems/cpukit/posix/src/psignalunblockthread.c:1.8 rtems/cpukit/posix/src/psignalunblockthread.c:1.8.2.1
--- rtems/cpukit/posix/src/psignalunblockthread.c:1.8	Thu Sep  4 10:23:12 2008
+++ rtems/cpukit/posix/src/psignalunblockthread.c	Sun Jul 31 17:41:06 2011
@@ -1,5 +1,5 @@
 /*
- *  COPYRIGHT (c) 1989-2007.
+ *  COPYRIGHT (c) 1989-2011.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -103,21 +103,16 @@
     if ( the_thread->current_state & STATES_INTERRUPTIBLE_BY_SIGNAL ) {
       the_thread->Wait.return_code = EINTR;
       /*
-       *  At this time, there is no RTEMS API object which lets a task
-       *  block on a thread queue and be interruptible by a POSIX signal.
-       *  If an object class with that requirement is ever added, enable
-       *  this code.
+       *  In pthread_cond_wait, a thread will be blocking on a thread
+       *  queue, but is also interruptible by a POSIX signal.
        */
-      #if 0
-	if ( _States_Is_waiting_on_thread_queue(the_thread->current_state) )
-	  _Thread_queue_Extract_with_proxy( the_thread );
-	else
-      #endif
-	  if ( _States_Is_delaying(the_thread->current_state) ){
-	    if ( _Watchdog_Is_active( &the_thread->Timer ) )
-	      (void) _Watchdog_Remove( &the_thread->Timer );
-	    _Thread_Unblock( the_thread );
-	  }
+      if ( _States_Is_waiting_on_thread_queue(the_thread->current_state) )
+        _Thread_queue_Extract_with_proxy( the_thread );
+      else if ( _States_Is_delaying(the_thread->current_state) ){
+	(void) _Watchdog_Remove( &the_thread->Timer );
+        _Thread_Unblock( the_thread );
+      }
+
     } else if ( the_thread->current_state == STATES_READY ) {
       if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
 	_ISR_Signals_to_thread_executing = TRUE;

diff -u rtems/cpukit/posix/src/psignalunblockthread.c:1.10 rtems/cpukit/posix/src/psignalunblockthread.c:1.10.2.1
--- rtems/cpukit/posix/src/psignalunblockthread.c:1.10	Mon Nov 30 09:44:21 2009
+++ rtems/cpukit/posix/src/psignalunblockthread.c	Sun Jul 31 17:40:43 2011
@@ -1,5 +1,5 @@
 /*
- *  COPYRIGHT (c) 1989-2007.
+ *  COPYRIGHT (c) 1989-2011.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -100,24 +100,19 @@
 
     the_thread->do_post_task_switch_extension = true;
 
-    if ( the_thread->current_state & STATES_INTERRUPTIBLE_BY_SIGNAL ) {
+    if ( _States_Is_interruptible_by_signal( the_thread->current_state ) ) {
       the_thread->Wait.return_code = EINTR;
       /*
-       *  At this time, there is no RTEMS API object which lets a task
-       *  block on a thread queue and be interruptible by a POSIX signal.
-       *  If an object class with that requirement is ever added, enable
-       *  this code.
+       *  In pthread_cond_wait, a thread will be blocking on a thread
+       *  queue, but is also interruptible by a POSIX signal.
        */
-      #if 0
-	if ( _States_Is_waiting_on_thread_queue(the_thread->current_state) )
-	  _Thread_queue_Extract_with_proxy( the_thread );
-	else
-      #endif
-	  if ( _States_Is_delaying(the_thread->current_state) ){
-	    if ( _Watchdog_Is_active( &the_thread->Timer ) )
-	      (void) _Watchdog_Remove( &the_thread->Timer );
-	    _Thread_Unblock( the_thread );
-	  }
+      if ( _States_Is_waiting_on_thread_queue(the_thread->current_state) )
+        _Thread_queue_Extract_with_proxy( the_thread );
+      else if ( _States_Is_delaying(the_thread->current_state) ){
+	(void) _Watchdog_Remove( &the_thread->Timer );
+        _Thread_Unblock( the_thread );
+      }
+
     } else if ( the_thread->current_state == STATES_READY ) {
       if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
 	_ISR_Signals_to_thread_executing = true;

diff -u rtems/cpukit/posix/src/pthread.c:1.68 rtems/cpukit/posix/src/pthread.c:1.68.2.1
--- rtems/cpukit/posix/src/pthread.c:1.68	Thu Sep  4 10:23:12 2008
+++ rtems/cpukit/posix/src/pthread.c	Sun Jul 31 17:41:06 2011
@@ -185,7 +185,7 @@
   _Thread_queue_Initialize(
     &api->Join_List,
     THREAD_QUEUE_DISCIPLINE_FIFO,
-    STATES_WAITING_FOR_JOIN_AT_EXIT,
+    STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
     0
   );
 

diff -u rtems/cpukit/posix/src/pthread.c:1.80 rtems/cpukit/posix/src/pthread.c:1.80.2.1
--- rtems/cpukit/posix/src/pthread.c:1.80	Sun Apr 25 14:51:12 2010
+++ rtems/cpukit/posix/src/pthread.c	Sun Jul 31 17:40:43 2011
@@ -214,7 +214,7 @@
   _Thread_queue_Initialize(
     &api->Join_List,
     THREAD_QUEUE_DISCIPLINE_FIFO,
-    STATES_WAITING_FOR_JOIN_AT_EXIT,
+    STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
     0
   );
 

diff -u rtems/cpukit/posix/src/pthreadjoin.c:1.8.4.2 rtems/cpukit/posix/src/pthreadjoin.c:1.8.4.3
--- rtems/cpukit/posix/src/pthreadjoin.c:1.8.4.2	Sun Jul 31 11:16:30 2011
+++ rtems/cpukit/posix/src/pthreadjoin.c	Sun Jul 31 17:40:43 2011
@@ -1,7 +1,7 @@
 /*
  *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
  *
- *  COPYRIGHT (c) 1989-2007.
+ *  COPYRIGHT (c) 1989-2011.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -32,6 +32,7 @@
   Objects_Locations        location;
   void                    *return_pointer;
 
+on_EINTR:
   the_thread = _Thread_Get( thread, &location );
   switch ( location ) {
 
@@ -66,6 +67,9 @@
       }
       _Thread_Enable_dispatch();
 
+      if ( _Thread_Executing->Wait.return_code == EINTR )
+        goto on_EINTR;
+
       if ( value_ptr )
         *value_ptr = return_pointer;
       return 0;

diff -u rtems/cpukit/posix/src/pthreadjoin.c:1.8.2.2 rtems/cpukit/posix/src/pthreadjoin.c:1.8.2.3
--- rtems/cpukit/posix/src/pthreadjoin.c:1.8.2.2	Sun Jul 31 11:16:55 2011
+++ rtems/cpukit/posix/src/pthreadjoin.c	Sun Jul 31 17:41:06 2011
@@ -1,7 +1,7 @@
 /*
  *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
  *
- *  COPYRIGHT (c) 1989-2007.
+ *  COPYRIGHT (c) 1989-2011.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -32,6 +32,7 @@
   Objects_Locations        location;
   void                    *return_pointer;
 
+on_EINTR:
   the_thread = _Thread_Get( thread, &location );
   switch ( location ) {
 
@@ -66,6 +67,9 @@
       }
       _Thread_Enable_dispatch();
 
+      if ( _Thread_Executing->Wait.return_code == EINTR )
+        goto on_EINTR;
+
       if ( value_ptr )
         *value_ptr = return_pointer;
       return 0;


 *joel* (on branch rtems-4-9-branch):
2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>

	PR 1855/cpukit
	* Makefile.am, configure.ac, psx16/Makefile.am: Correct signal
	processing during pthread_join. We are supposed to unblock the thread
	waiting on a pthread_join(), dispatch the signal handler, account for
	it potentially overwriting errno, and then have the thread return to
	blocking within pthread_join().
	* psxeintr_join/.cvsignore, psxeintr_join/Makefile.am,
	psxeintr_join/init.c, psxeintr_join/psxeintr_join.doc,
	psxeintr_join/psxeintr_join.scn: New files.

M 1.125.2.2  testsuites/psxtests/ChangeLog
M 1.32.2.2  testsuites/psxtests/Makefile.am
M 1.31.2.2  testsuites/psxtests/configure.ac
M 1.1.4.3  testsuites/psxtests/psx16/Makefile.am
M 1.1.4.2  testsuites/psxtests/psxeintr_join/.cvsignore
M 1.1.4.2  testsuites/psxtests/psxeintr_join/Makefile.am
M 1.1.4.2  testsuites/psxtests/psxeintr_join/init.c
M 1.1.4.2  testsuites/psxtests/psxeintr_join/psxeintr_join.doc
M 1.1.4.2  testsuites/psxtests/psxeintr_join/psxeintr_join.scn

diff -u rtems/testsuites/psxtests/ChangeLog:1.125.2.1 rtems/testsuites/psxtests/ChangeLog:1.125.2.2
--- rtems/testsuites/psxtests/ChangeLog:1.125.2.1	Sun Jul 31 11:17:02 2011
+++ rtems/testsuites/psxtests/ChangeLog	Sun Jul 31 17:41:16 2011
@@ -1,5 +1,17 @@
 2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
+	PR 1855/cpukit
+	* Makefile.am, configure.ac, psx16/Makefile.am: Correct signal
+	processing during pthread_join. We are supposed to unblock the thread
+	waiting on a pthread_join(), dispatch the signal handler, account for
+	it potentially overwriting errno, and then have the thread return to
+	blocking within pthread_join().
+	* psxeintr_join/.cvsignore, psxeintr_join/Makefile.am,
+	psxeintr_join/init.c, psxeintr_join/psxeintr_join.doc,
+	psxeintr_join/psxeintr_join.scn: New files.
+
+2011-07-31	Joel Sherrill <joel.sherrilL at OARcorp.com>
+
 	PR 1867/cpukit
 	* Makefile.am, configure.ac, psx12/task.c, psxrwlock01/test.c: Correct
 	implementation of pthread_exit() and pthread_join() to support the

diff -u rtems/testsuites/psxtests/Makefile.am:1.32.2.1 rtems/testsuites/psxtests/Makefile.am:1.32.2.2
--- rtems/testsuites/psxtests/Makefile.am:1.32.2.1	Sun Jul 31 11:17:02 2011
+++ rtems/testsuites/psxtests/Makefile.am	Sun Jul 31 17:41:17 2011
@@ -6,9 +6,9 @@
 
 SUBDIRS = psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
     psx10 psx11 psx12 psx13 psx14 psx16 psxcleanup psxtime psxtimer01 \
-    psxtimer02 psxcancel psxbarrier01 psxmsgq01 psxmsgq02 psxrwlock01
-    psxsem01 psxspin01 psxenosys psxsignal01 psxsysconf psxualarm psxkey01 \
-    psxfatal01 psxfatal02
+    psxtimer02 psxcancel psxbarrier01 psxmsgq01 psxmsgq02 psxrwlock01 \
+    psxsem01 psxspin01 psxeintr_join psxenosys psxsignal01 psxsysconf \
+    psxualarm psxkey01 psxfatal01 psxfatal02
 
 ## File IO tests
 SUBDIRS += psxfile01 psxreaddir psxstat psxmount psx13 psxchroot01 

diff -u rtems/testsuites/psxtests/configure.ac:1.31.2.1 rtems/testsuites/psxtests/configure.ac:1.31.2.2
--- rtems/testsuites/psxtests/configure.ac:1.31.2.1	Sun Jul 31 11:17:02 2011
+++ rtems/testsuites/psxtests/configure.ac	Sun Jul 31 17:41:17 2011
@@ -46,6 +46,7 @@
 psxcancel/Makefile
 psxchroot01/Makefile
 psxcleanup/Makefile
+psxeintr_join/Makefile
 psxenosys/Makefile
 psxfatal01/Makefile
 psxfatal02/Makefile

diff -u rtems/testsuites/psxtests/psx16/Makefile.am:1.1.4.2 rtems/testsuites/psxtests/psx16/Makefile.am:1.1.4.3
--- rtems/testsuites/psxtests/psx16/Makefile.am:1.1.4.2	Sun Jul 31 11:17:02 2011
+++ rtems/testsuites/psxtests/psx16/Makefile.am	Sun Jul 31 17:41:17 2011
@@ -2,24 +2,27 @@
 ## $Id$
 ##
 
-rtems_tests_PROGRAMS = psx16
-psx16_SOURCES = init.c
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psx16.exe
+psx16_exe_SOURCES = init.c
 
 dist_rtems_tests_DATA = psx16.scn
-dist_rtems_tests_DATA += psx16.doc
 
 include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
 include $(top_srcdir)/../automake/compile.am
 include $(top_srcdir)/../automake/leaf.am
 
+psx16_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
 AM_CPPFLAGS += -I$(top_srcdir)/include
 AM_CPPFLAGS += -I$(top_srcdir)/../support/include
 
-LINK_OBJS = $(psx16_OBJECTS) $(psx16_LDADD)
-LINK_LIBS = $(psx16_LDLIBS)
+LINK_OBJS = $(psx16_exe_OBJECTS) $(psx16_exe_LDADD)
+LINK_LIBS = $(psx16_exe_LDLIBS)
 
-psx16$(EXEEXT): $(psx16_OBJECTS) $(psx16_DEPENDENCIES)
-	@rm -f psx16$(EXEEXT)
+psx16.exe$(EXEEXT): $(psx16_exe_OBJECTS) $(psx16_exe_DEPENDENCIES)
+	@rm -f psx16.exe$(EXEEXT)
 	$(make-exe)
 
 include $(top_srcdir)/../automake/local.am

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/.cvsignore:1.1.4.2
--- /dev/null	Sun Jul 31 18:11:03 2011
+++ rtems/testsuites/psxtests/psxeintr_join/.cvsignore	Sun Jul 31 17:41:17 2011
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/Makefile.am:1.1.4.2
--- /dev/null	Sun Jul 31 18:11:03 2011
+++ rtems/testsuites/psxtests/psxeintr_join/Makefile.am	Sun Jul 31 17:41:17 2011
@@ -0,0 +1,28 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = psxeintr_join.exe
+psxeintr_join_exe_SOURCES = init.c
+
+dist_rtems_tests_DATA = psxeintr_join.scn
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+psxeintr_join_exe_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(psxeintr_join_exe_OBJECTS) $(psxeintr_join_exe_LDADD)
+LINK_LIBS = $(psxeintr_join_exe_LDLIBS)
+
+psxeintr_join.exe$(EXEEXT): $(psxeintr_join_exe_OBJECTS) $(psxeintr_join_exe_DEPENDENCIES)
+	@rm -f psxeintr_join.exe$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/init.c:1.1.4.2
--- /dev/null	Sun Jul 31 18:11:03 2011
+++ rtems/testsuites/psxtests/psxeintr_join/init.c	Sun Jul 31 17:41:17 2011
@@ -0,0 +1,125 @@
+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <pthread.h>
+
+#include <rtems.h>
+#include <tmacros.h>
+#include "test_support.h"
+
+#define SIG_SUSPEND SIGUSR1
+#define SIG_THR_RESTART SIGUSR2
+
+sem_t GC_suspend_ack_sem;
+
+static void print_sig_mask( const char * str )
+{
+  sigset_t blocked;
+  int      i;
+  int      status;
+
+  status = pthread_sigmask( SIG_BLOCK, NULL, &blocked );
+  rtems_test_assert( status == 0 );
+
+  printf( "%s blocked:\n", str );
+  for ( i = 1; i < NSIG; i++) {
+    if ( sigismember( &blocked, i ) )
+      printf( "%d ", i );
+  }
+  printf( "\n" );
+}
+
+void GC_suspend_handler( int sig )
+{
+  puts( "run in GC_suspend_handler" );
+  sem_post( &GC_suspend_ack_sem );
+}
+
+void GC_restart_handler( int sig )
+{
+  puts( "run in GC_restart_handler" );
+}
+
+void* run( void *arg )
+{
+  int       status;
+  pthread_t id = *(pthread_t *)arg;
+
+  print_sig_mask( "New Thread" );
+
+  status = pthread_kill( id, SIG_SUSPEND );
+  rtems_test_assert( status == 0 );
+
+  puts( "New Thread: after pthread_kill" );
+  status = sem_wait( &GC_suspend_ack_sem );
+  rtems_test_assert( status == 0 );
+
+  puts( "New Thread over!" );
+  return NULL;
+}
+
+void *POSIX_Init( void *arg )
+{
+  struct sigaction act;
+  pthread_t        newThread;
+  pthread_t        mainThread;
+  int              status;
+
+  puts( "*** POSIX TEST PSXEINTR_JOIN ***" );
+  status = sem_init( &GC_suspend_ack_sem, 0, 0);
+  rtems_test_assert( status == 0 );
+
+  status = sigemptyset( &act.sa_mask );
+  rtems_test_assert( status == 0 );
+
+  status = sigaddset( &act.sa_mask, SIG_SUSPEND );
+  rtems_test_assert( status == 0 );
+
+  status = pthread_sigmask( SIG_UNBLOCK, &act.sa_mask, NULL );
+  rtems_test_assert( status == 0 );
+
+  act.sa_handler = GC_suspend_handler;
+
+  status = sigaction( SIG_SUSPEND, &act, NULL );
+  rtems_test_assert( status == 0 );
+
+  act.sa_handler = GC_restart_handler;
+
+  print_sig_mask( "Main Thread" );
+
+  mainThread = pthread_self();
+  status = pthread_create( &newThread, NULL, run, &mainThread );
+  rtems_test_assert( status == 0 );
+
+  pthread_join( newThread, NULL );
+  puts( "Back from pthread_join" );
+
+  puts( "*** END OF POSIX TEST PSXEINTR_JOIN ***" );
+  rtems_test_exit( 0 );
+
+  return NULL;
+}
+
+/* configuration information */
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
+#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
+

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.doc:1.1.4.2
--- /dev/null	Sun Jul 31 18:11:03 2011
+++ rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.doc	Sun Jul 31 17:41:17 2011
@@ -0,0 +1,24 @@
+#
+#  $Id$
+#
+#  COPYRIGHT (c) 1989-2011.
+#  On-Line Applications Research Corporation (OAR).
+#
+#  The license and distribution terms for this file may be
+#  found in the file LICENSE in this distribution or at
+#  http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name:  psxeintr_join
+
+directives:
+
+  + pthread_join
+  + pthread_kill
+
+concepts:
+
++ Verify that a signal sent during a blocking pthread_join() call is properly
+  processed.

diff -u /dev/null rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.scn:1.1.4.2
--- /dev/null	Sun Jul 31 18:11:03 2011
+++ rtems/testsuites/psxtests/psxeintr_join/psxeintr_join.scn	Sun Jul 31 17:41:17 2011
@@ -0,0 +1,9 @@
+*** POSIX TEST PSXEINTR_JOIN ***
+Main Thread blocked: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 27 28 29 30 31 
+New Thread blocked: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 27 28 29 30 31 
+New Thread: after pthread_kill
+run in GC_suspend_handler
+New Thread over!
+Back from pthread_join
+*** END OF POSIX TEST PSXEINTR_JOIN ***
+



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20110731/1a387fa9/attachment-0001.html>


More information about the vc mailing list