Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Ticket #1855: pr1855_411.diff

File pr1855_411.diff, 10.0 KB (added by Joel Sherrill, on 07/31/11 at 21:45:57)

Patch for 4.11

  • cpukit/posix/src/psignal.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/psignal.c,v
    retrieving revision 1.70
    diff -u -r1.70 psignal.c
     
    112112  POSIX_API_Control  *api;
    113113  int                 signo;
    114114  ISR_Level           level;
     115  int                 hold_errno;
    115116
    116117  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
    117118
    118119  /*
     120   *  We need to ensure that if the signal handler executes a call
     121   *  which overwrites the unblocking status, we restore it.
     122   */
     123  hold_errno = _Thread_Executing->Wait.return_code;
     124
     125  /*
    119126   * api may be NULL in case of a thread close in progress
    120127   */
    121128  if ( !api )
     
    149156      _POSIX_signals_Check_signal( api, signo, true );
    150157    }
    151158  }
     159
     160  _Thread_Executing->Wait.return_code = hold_errno;
    152161}
    153162
    154163/*
  • cpukit/posix/src/pthread.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/pthread.c,v
    retrieving revision 1.84
    diff -u -r1.84 pthread.c
     
    217217  _Thread_queue_Initialize(
    218218    &api->Join_List,
    219219    THREAD_QUEUE_DISCIPLINE_FIFO,
    220     STATES_WAITING_FOR_JOIN_AT_EXIT,
     220    STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
    221221    0
    222222  );
    223223
  • cpukit/posix/src/pthreadjoin.c

    RCS file: /usr1/CVS/rtems/cpukit/posix/src/pthreadjoin.c,v
    retrieving revision 1.12
    diff -u -r1.12 pthreadjoin.c
     
    11/*
    22 *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
    33 *
    4  *  COPYRIGHT (c) 1989-2007.
     4 *  COPYRIGHT (c) 1989-2011.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
    77 *  The license and distribution terms for this file may be
     
    3232  Objects_Locations        location;
    3333  void                    *return_pointer;
    3434
     35on_EINTR:
    3536  the_thread = _Thread_Get( thread, &location );
    3637  switch ( location ) {
    3738
     
    6667      }
    6768      _Thread_Enable_dispatch();
    6869
     70      if ( _Thread_Executing->Wait.return_code == EINTR )
     71        goto on_EINTR;
     72
    6973      if ( value_ptr )
    7074        *value_ptr = return_pointer;
    7175      return 0;
  • testsuites/psxtests/Makefile.am

    RCS file: /usr1/CVS/rtems/testsuites/psxtests/Makefile.am,v
    retrieving revision 1.76
    diff -u -r1.76 Makefile.am
     
    1717    psxsignal03 psxsignal04 psxsignal05 psxsignal06 \
    1818    psxspin01 psxspin02 psxsysconf \
    1919    psxtime psxtimer01 psxtimer02 psxualarm psxusleep psxfatal01 psxfatal02 \
    20     psxintrcritical01 psxstack01 psxstack02
     20    psxintrcritical01 psxstack01 psxstack02 \
     21    psxeintr_join
    2122endif
    2223
    2324## File IO tests
  • testsuites/psxtests/configure.ac

    RCS file: /usr1/CVS/rtems/testsuites/psxtests/configure.ac,v
    retrieving revision 1.84
    diff -u -r1.84 configure.ac
     
    112112psxcleanup01/Makefile
    113113psxclock/Makefile
    114114psxcond01/Makefile
     115psxeintr_join/Makefile
    115116psxenosys/Makefile
    116117psxfatal01/Makefile
    117118psxfatal02/Makefile
  • new file testsuites/psxtests/psxeintr_join/.cvsignore

    RCS file: testsuites/psxtests/psxeintr_join/.cvsignore
    diff -N testsuites/psxtests/psxeintr_join/.cvsignore
    - +  
     1Makefile
     2Makefile.in
  • new file testsuites/psxtests/psxeintr_join/Makefile.am

    RCS file: testsuites/psxtests/psxeintr_join/Makefile.am
    diff -N testsuites/psxtests/psxeintr_join/Makefile.am
    - +  
     1##
     2## $Id: Makefile.am,v 1.1 2010/11/05 19:33:03 joel Exp $
     3##
     4
     5rtems_tests_PROGRAMS = psxeintr_join
     6psxeintr_join_SOURCES = init.c
     7
     8dist_rtems_tests_DATA = psxeintr_join.scn
     9dist_rtems_tests_DATA += psxeintr_join.doc
     10
     11include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
     12include $(top_srcdir)/../automake/compile.am
     13include $(top_srcdir)/../automake/leaf.am
     14
     15AM_CPPFLAGS += -I$(top_srcdir)/include
     16AM_CPPFLAGS += -I$(top_srcdir)/../support/include
     17
     18LINK_OBJS = $(psxeintr_join_OBJECTS) $(psxeintr_join_LDADD)
     19LINK_LIBS = $(psxeintr_join_LDLIBS)
     20
     21psxeintr_join$(EXEEXT): $(psxeintr_join_OBJECTS) $(psxeintr_join_DEPENDENCIES)
     22        @rm -f psxeintr_join$(EXEEXT)
     23        $(make-exe)
     24
     25include $(top_srcdir)/../automake/local.am
  • new file testsuites/psxtests/psxeintr_join/init.c

    RCS file: testsuites/psxtests/psxeintr_join/init.c
    diff -N testsuites/psxtests/psxeintr_join/init.c
    - +  
     1/*
     2 *  COPYRIGHT (c) 1989-2011.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
     9 *  $Id$
     10 */
     11
     12#include <stdio.h>
     13#include <signal.h>
     14#include <semaphore.h>
     15#include <pthread.h>
     16
     17#include <rtems.h>
     18#include <tmacros.h>
     19#include "test_support.h"
     20
     21#define SIG_SUSPEND SIGUSR1
     22#define SIG_THR_RESTART SIGUSR2
     23
     24sem_t GC_suspend_ack_sem;
     25
     26static void print_sig_mask( const char * str )
     27{
     28  sigset_t blocked;
     29  int      i;
     30  int      status;
     31
     32  status = pthread_sigmask( SIG_BLOCK, NULL, &blocked );
     33  rtems_test_assert( status == 0 );
     34
     35  printf( "%s blocked:\n", str );
     36  for ( i = 1; i < NSIG; i++) {
     37    if ( sigismember( &blocked, i ) )
     38      printf( "%d ", i );
     39  }
     40  printf( "\n" );
     41}
     42
     43void GC_suspend_handler( int sig )
     44{
     45  puts( "run in GC_suspend_handler" );
     46  sem_post( &GC_suspend_ack_sem );
     47}
     48
     49void GC_restart_handler( int sig )
     50{
     51  puts( "run in GC_restart_handler" );
     52}
     53
     54void* run( void *arg )
     55{
     56  int       status;
     57  pthread_t id = *(pthread_t *)arg;
     58
     59  print_sig_mask( "New Thread" );
     60
     61  status = pthread_kill( id, SIG_SUSPEND );
     62  rtems_test_assert( status == 0 );
     63
     64  puts( "New Thread: after pthread_kill" );
     65  status = sem_wait( &GC_suspend_ack_sem );
     66  rtems_test_assert( status == 0 );
     67
     68  puts( "New Thread over!" );
     69  return NULL;
     70}
     71
     72void *POSIX_Init( void *arg )
     73{
     74  struct sigaction act;
     75  pthread_t        newThread;
     76  pthread_t        mainThread;
     77  int              status;
     78
     79  puts( "*** POSIX TEST PSXEINTR_JOIN ***" );
     80  status = sem_init( &GC_suspend_ack_sem, 0, 0);
     81  rtems_test_assert( status == 0 );
     82
     83  status = sigemptyset( &act.sa_mask );
     84  rtems_test_assert( status == 0 );
     85
     86  status = sigaddset( &act.sa_mask, SIG_SUSPEND );
     87  rtems_test_assert( status == 0 );
     88
     89  status = pthread_sigmask( SIG_UNBLOCK, &act.sa_mask, NULL );
     90  rtems_test_assert( status == 0 );
     91
     92  act.sa_handler = GC_suspend_handler;
     93
     94  status = sigaction( SIG_SUSPEND, &act, NULL );
     95  rtems_test_assert( status == 0 );
     96
     97  act.sa_handler = GC_restart_handler;
     98
     99  print_sig_mask( "Main Thread" );
     100
     101  mainThread = pthread_self();
     102  status = pthread_create( &newThread, NULL, run, &mainThread );
     103  rtems_test_assert( status == 0 );
     104
     105  pthread_join( newThread, NULL );
     106  puts( "Back from pthread_join" );
     107
     108  puts( "*** END OF POSIX TEST PSXEINTR_JOIN ***" );
     109  rtems_test_exit( 0 );
     110
     111  return NULL;
     112}
     113
     114/* configuration information */
     115#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     116#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     117
     118#define CONFIGURE_POSIX_INIT_THREAD_TABLE
     119#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
     120#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
     121
     122#define CONFIGURE_INIT
     123#include <rtems/confdefs.h>
     124/* end of file */
     125
  • new file testsuites/psxtests/psxeintr_join/psxeintr_join.doc

    RCS file: testsuites/psxtests/psxeintr_join/psxeintr_join.doc
    diff -N testsuites/psxtests/psxeintr_join/psxeintr_join.doc
    - +  
     1#
     2#  $Id: TEST.doc,v 1.1 2010/06/21 12:37:11 joel Exp $
     3#
     4#  COPYRIGHT (c) 1989-2011.
     5#  On-Line Applications Research Corporation (OAR).
     6#
     7#  The license and distribution terms for this file may be
     8#  found in the file LICENSE in this distribution or at
     9#  http://www.rtems.com/license/LICENSE.
     10#
     11
     12This file describes the directives and concepts tested by this test set.
     13
     14test set name:  psxeintr_join
     15
     16directives:
     17
     18  + pthread_join
     19  + pthread_kill
     20
     21concepts:
     22
     23+ Verify that a signal sent during a blocking pthread_join() call is properly
     24  processed.
  • new file testsuites/psxtests/psxeintr_join/psxeintr_join.scn

    RCS file: testsuites/psxtests/psxeintr_join/psxeintr_join.scn
    diff -N testsuites/psxtests/psxeintr_join/psxeintr_join.scn
    - +  
     1*** POSIX TEST PSXEINTR_JOIN ***
     2Main 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
     3New 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
     4New Thread: after pthread_kill
     5run in GC_suspend_handler
     6New Thread over!
     7Back from pthread_join
     8*** END OF POSIX TEST PSXEINTR_JOIN ***
     9