diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-06-11 16:04:25 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-06-11 16:04:25 +0000 |
commit | fb39f191da0ee2ae9e00deedc30ffe1485b1855c (patch) | |
tree | d42c5eb2d2dfdf5be11177f1bbf0b48dabfaae0b /c/src/tests/psxtests/psx02/init.c | |
parent | Interruptible by signals state was added to the STATES_BLOCKED set. It (diff) | |
download | rtems-fb39f191da0ee2ae9e00deedc30ffe1485b1855c.tar.bz2 |
modified to test pthread_kill() to self and pthread_kill() to a blocked
thread. nanosleep() can be interrupted and return the time remaining.
Diffstat (limited to 'c/src/tests/psxtests/psx02/init.c')
-rw-r--r-- | c/src/tests/psxtests/psx02/init.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/c/src/tests/psxtests/psx02/init.c b/c/src/tests/psxtests/psx02/init.c index 22ec11f45a..cd017e62eb 100644 --- a/c/src/tests/psxtests/psx02/init.c +++ b/c/src/tests/psxtests/psx02/init.c @@ -12,6 +12,7 @@ #define CONFIGURE_INIT #include "system.h" +#include <signal.h> 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 ", |