From fb39f191da0ee2ae9e00deedc30ffe1485b1855c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 11 Jun 1996 16:04:25 +0000 Subject: modified to test pthread_kill() to self and pthread_kill() to a blocked thread. nanosleep() can be interrupted and return the time remaining. --- testsuites/psxtests/psx02/init.c | 26 +++++++++++++++++++++----- testsuites/psxtests/psx02/task.c | 6 +++--- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'testsuites/psxtests/psx02') diff --git a/testsuites/psxtests/psx02/init.c b/testsuites/psxtests/psx02/init.c index 22ec11f45a..cd017e62eb 100644 --- a/testsuites/psxtests/psx02/init.c +++ b/testsuites/psxtests/psx02/init.c @@ -12,6 +12,7 @@ #define CONFIGURE_INIT #include "system.h" +#include volatile int Signal_occurred; @@ -19,7 +20,7 @@ void Signal_handler( int signo ) { - printf( "Signal: %d caught\n", signo ); + printf( "Signal: %d caught by 0x%x\n", signo, pthread_self() ); Signal_occurred = 1; } @@ -27,9 +28,10 @@ void *POSIX_Init( void *argument ) { - int status; - struct timespec tv; - struct timespec tr; + int status; + struct timespec tv; + struct timespec tr; + struct sigaction act; puts( "\n\n*** POSIX TEST 2 ***" ); @@ -42,6 +44,21 @@ void *POSIX_Init( Init_id = pthread_self(); printf( "Init's ID is 0x%08x\n", Init_id ); + /* install a signal handler */ + + status = sigemptyset( &act.sa_mask ); + assert( !status ); + + act.sa_handler = Signal_handler; + act.sa_flags = 0; + + sigaction( SIGUSR1, &act, NULL ); + + /* simple signal to self */ + + status = pthread_kill( Init_id, SIGUSR1 ); + assert( !status ); + /* create a thread */ status = pthread_create( &Task_id, NULL, Task_1_through_3, NULL ); @@ -62,7 +79,6 @@ void *POSIX_Init( status = nanosleep ( &tv, &tr ); assert( !status ); - print_current_time( "Init: ", "" ); printf( "Init: signal was %sprocessed with %d:%d time remaining\n", (Signal_occurred) ? "" : "not ", diff --git a/testsuites/psxtests/psx02/task.c b/testsuites/psxtests/psx02/task.c index 354a32bb0e..410ee32346 100644 --- a/testsuites/psxtests/psx02/task.c +++ b/testsuites/psxtests/psx02/task.c @@ -31,12 +31,12 @@ void *Task_1_through_3( int status; for ( i=0 ; i<5 ; i++ ) { - seconds = sleep( 1 ); - assert( !seconds ); - print_current_time( "Task1: ", "" ); status = pthread_kill( Init_id, SIGUSR1 ); assert( !status ); + + seconds = sleep( 1 ); + assert( !seconds ); } puts( "*** END OF POSIX TEST 2 ***" ); exit( 0 ); -- cgit v1.2.3