summaryrefslogtreecommitdiffstats
path: root/c/src/tests/psxtests/psx02
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-11 16:04:25 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-11 16:04:25 +0000
commitfb39f191da0ee2ae9e00deedc30ffe1485b1855c (patch)
treed42c5eb2d2dfdf5be11177f1bbf0b48dabfaae0b /c/src/tests/psxtests/psx02
parentInterruptible by signals state was added to the STATES_BLOCKED set. It (diff)
downloadrtems-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')
-rw-r--r--c/src/tests/psxtests/psx02/init.c26
-rw-r--r--c/src/tests/psxtests/psx02/task.c6
2 files changed, 24 insertions, 8 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 ",
diff --git a/c/src/tests/psxtests/psx02/task.c b/c/src/tests/psxtests/psx02/task.c
index 354a32bb0e..410ee32346 100644
--- a/c/src/tests/psxtests/psx02/task.c
+++ b/c/src/tests/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 );