File indexing completed on 2025-05-11 08:24:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #define CONFIGURE_INIT
0034 #include "system.h"
0035 #include <signal.h>
0036
0037 const char rtems_test_name[] = "PSX 2";
0038
0039 volatile int Signal_occurred;
0040 volatile int Signal_count;
0041 void Signal_handler( int signo );
0042
0043 void Signal_handler(
0044 int signo
0045 )
0046 {
0047 Signal_count++;
0048 printf(
0049 "Signal: %d caught by 0x%x (%d)\n",
0050 (int) signo,
0051 (unsigned int) pthread_self(),
0052 Signal_count
0053 );
0054 Signal_occurred = 1;
0055 }
0056
0057 void *POSIX_Init(
0058 void *argument
0059 )
0060 {
0061 int status;
0062 struct timespec tv;
0063 struct timespec tr;
0064 struct sigaction act;
0065 sigset_t mask;
0066 sigset_t pending_set;
0067
0068 TEST_BEGIN();
0069
0070
0071
0072 set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
0073
0074
0075
0076 Init_id = pthread_self();
0077 printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
0078
0079
0080
0081 status = sigemptyset( &act.sa_mask );
0082 rtems_test_assert( !status );
0083
0084 act.sa_handler = Signal_handler;
0085 act.sa_flags = 0;
0086
0087 sigaction( SIGUSR1, &act, NULL );
0088
0089
0090
0091 Signal_count = 0;
0092 Signal_occurred = 0;
0093
0094 status = pthread_kill( Init_id, SIGUSR1 );
0095 rtems_test_assert( !status );
0096
0097 Signal_occurred = 0;
0098
0099
0100
0101 status = sigemptyset( &mask );
0102 rtems_test_assert( !status );
0103
0104 status = sigaddset( &mask, SIGUSR1 );
0105 rtems_test_assert( !status );
0106
0107 printf( "Init: Block SIGUSR1\n" );
0108 status = sigprocmask( SIG_BLOCK, &mask, NULL );
0109 rtems_test_assert( !status );
0110
0111 status = sigpending( &pending_set );
0112 rtems_test_assert( !status );
0113 printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
0114
0115
0116 printf( "Init: send SIGUSR1 to self\n" );
0117 status = pthread_kill( Init_id, SIGUSR1 );
0118 rtems_test_assert( !status );
0119
0120 status = sigpending( &pending_set );
0121 rtems_test_assert( !status );
0122 printf( "Init: Signals pending 0x%08x\n", (unsigned int) pending_set );
0123
0124 printf( "Init: Unblock SIGUSR1\n" );
0125 status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
0126 rtems_test_assert( !status );
0127
0128
0129
0130 status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL );
0131 rtems_test_assert( !status );
0132
0133
0134
0135
0136
0137 tr.tv_sec = 5;
0138 tr.tv_nsec = 0;
0139
0140 do {
0141 tv = tr;
0142
0143 Signal_occurred = 0;
0144
0145 status = nanosleep ( &tv, &tr );
0146
0147 if ( status == -1 ) {
0148 rtems_test_assert( errno == EINTR );
0149 rtems_test_assert( tr.tv_nsec || tr.tv_sec );
0150 } else if ( !status ) {
0151 rtems_test_assert( !tr.tv_nsec && !tr.tv_sec );
0152 }
0153
0154 printf(
0155 "Init: signal was %sprocessed with %d:%d time remaining\n",
0156 (Signal_occurred) ? "" : "not ",
0157 (int) tr.tv_sec,
0158 (int) tr.tv_nsec
0159 );
0160
0161 } while ( tr.tv_sec || tr.tv_nsec );
0162
0163
0164
0165 TEST_END();
0166 rtems_test_exit( 0 );
0167
0168 return NULL;
0169 }