mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-28 23:19:18 +08:00
2009-07-29 Joel Sherrill <joel.sherrill@OARcorp.com>
* Makefile.am, configure.ac: Add test to address cases where a thread is waiting on a signal (sigwait) and we send it. Also address case where there are too many queued signals. * psxsignal03/.cvsignore, psxsignal03/Makefile.am, psxsignal03/init.c, psxsignal03/psxsignal03.doc, psxsignal03/psxsignal03.scn: New files.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2009-07-29 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* Makefile.am, configure.ac: Add test to address cases where a thread
|
||||
is waiting on a signal (sigwait) and we send it. Also address case
|
||||
where there are too many queued signals.
|
||||
* psxsignal03/.cvsignore, psxsignal03/Makefile.am, psxsignal03/init.c,
|
||||
psxsignal03/psxsignal03.doc, psxsignal03/psxsignal03.scn: New files.
|
||||
|
||||
2009-07-29 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* psxsignal02/init.c: Fix spacing.
|
||||
|
||||
@@ -8,8 +8,8 @@ SUBDIRS = psxhdrs psx01 psx02 psx03 psx04 psx05 psx06 psx07 psx08 psx09 \
|
||||
psx10 psx11 psx12 psx13 psx14 psxautoinit01 psxautoinit02 psxbarrier01 \
|
||||
psxcancel psxcleanup psxcond01 psxenosys psxkey01 psxitimer psxmsgq01 \
|
||||
psxmsgq02 psxmsgq03 psxmutexattr01 psxobj01 psxrwlock01 psxsem01 \
|
||||
psxsignal01 psxsignal02 psxspin01 psxspin02 psxsysconf psxtime psxtimer01 \
|
||||
psxtimer02 psxualarm \
|
||||
psxsignal01 psxsignal02 psxsignal03 psxspin01 psxspin02 psxsysconf \
|
||||
psxtime psxtimer01 psxtimer02 psxualarm \
|
||||
psxfatal01 psxfatal02 \
|
||||
psxintrcritical01
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ psxrwlock01/Makefile
|
||||
psxsem01/Makefile
|
||||
psxsignal01/Makefile
|
||||
psxsignal02/Makefile
|
||||
psxsignal03/Makefile
|
||||
psxspin01/Makefile
|
||||
psxspin02/Makefile
|
||||
psxstat/Makefile
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -0,0 +1,29 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
MANAGERS = all
|
||||
|
||||
rtems_tests_PROGRAMS = psxsignal03
|
||||
psxsignal03_SOURCES = init.c ../include/pmacros.h
|
||||
|
||||
dist_rtems_tests_DATA = psxsignal03.scn
|
||||
dist_rtems_tests_DATA += psxsignal03.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
psxsignal03_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/include
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(psxsignal03_OBJECTS) $(psxsignal03_LDADD)
|
||||
LINK_LIBS = $(psxsignal03_LDLIBS)
|
||||
|
||||
psxsignal03$(EXEEXT): $(psxsignal03_OBJECTS) $(psxsignal03_DEPENDENCIES)
|
||||
@rm -f psxsignal03$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
#include <pmacros.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
|
||||
volatile bool Signal_occurred;
|
||||
volatile pthread_t Signal_thread;
|
||||
|
||||
void Signal_handler(
|
||||
int signo,
|
||||
siginfo_t *info,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
Signal_occurred = true;
|
||||
Signal_thread = pthread_self();
|
||||
}
|
||||
|
||||
void *Test_Thread(void *arg)
|
||||
{
|
||||
bool blocked = *((bool *)arg);
|
||||
const char *name;
|
||||
int sc;
|
||||
sigset_t mask;
|
||||
sigset_t wait_mask;
|
||||
sigset_t pending_set;
|
||||
sigset_t oset;
|
||||
siginfo_t info;
|
||||
|
||||
if ( blocked )
|
||||
name = "SignalBlocked";
|
||||
else
|
||||
name = "SignalNotBlocked";
|
||||
|
||||
/* build unblocked mask */
|
||||
sc = sigemptyset( &mask );
|
||||
assert( !sc );
|
||||
|
||||
printf( "%s - Unblock SIGUSR1\n", name );
|
||||
sc = sigaddset( &mask, SIGUSR1 );
|
||||
assert( !sc );
|
||||
|
||||
if ( !blocked ) {
|
||||
printf( "%s - Unblock SIGUSR2\n", name );
|
||||
sc = sigaddset( &mask, SIGUSR2 );
|
||||
assert( !sc );
|
||||
}
|
||||
|
||||
/* unblocked signals */
|
||||
sc = pthread_sigmask( SIG_UNBLOCK, &mask, NULL );
|
||||
assert( !sc );
|
||||
|
||||
/* build wait mask */
|
||||
sc = sigemptyset( &wait_mask );
|
||||
assert( !sc );
|
||||
|
||||
sc = sigaddset( &wait_mask, SIGUSR1 );
|
||||
assert( !sc );
|
||||
|
||||
/* wait for a signal */
|
||||
memset( &info, 0, sizeof(info) );
|
||||
|
||||
printf( "%s - Wait for SIGUSR1 unblocked\n", name );
|
||||
sigwaitinfo( &wait_mask, &info );
|
||||
assert( !sc );
|
||||
|
||||
printf( "%s - siginfo.si_signo=%d\n", name, info.si_signo );
|
||||
printf( "%s - siginfo.si_code=%d\n", name, info.si_code );
|
||||
printf( "%s - siginfo.si_value=0x%08x\n", name, info.si_value );
|
||||
|
||||
assert( info.si_signo == SIGUSR2 );
|
||||
assert( info.si_code == SI_USER );
|
||||
|
||||
printf( "%s - exiting\n", name );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *POSIX_Init(
|
||||
void *argument
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int sc;
|
||||
pthread_t id;
|
||||
struct sigaction act;
|
||||
bool trueArg = true;
|
||||
bool falseArg = false;
|
||||
|
||||
puts( "\n\n*** POSIX TEST SIGNAL 03 ***" );
|
||||
|
||||
Signal_occurred = false;
|
||||
|
||||
act.sa_handler = NULL;
|
||||
act.sa_sigaction = Signal_handler;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
sigaction( SIGUSR1, &act, NULL );
|
||||
sigaction( SIGUSR2, &act, NULL );
|
||||
|
||||
/* create threads */
|
||||
sc = pthread_create( &id, NULL, Test_Thread, &falseArg );
|
||||
assert( !sc );
|
||||
|
||||
sc = pthread_create( &id, NULL, Test_Thread, &trueArg );
|
||||
assert( !sc );
|
||||
|
||||
puts( "Init - sleep - let threads settle - OK" );
|
||||
usleep(500000);
|
||||
|
||||
puts( "Init - sleep - SignalBlocked thread settle - OK" );
|
||||
usleep(500000);
|
||||
|
||||
puts( "Init - sending SIGUSR2 - deliver to one thread" );
|
||||
sc = kill( getpid(), SIGUSR2 );
|
||||
assert( !sc );
|
||||
|
||||
puts( "Init - sending SIGUSR2 - deliver to other thread" );
|
||||
sc = kill( getpid(), SIGUSR2 );
|
||||
assert( !sc );
|
||||
|
||||
puts( "Init - sending SIGUSR2 - expect EAGAIN" );
|
||||
sc = kill( getpid(), SIGUSR2 );
|
||||
assert( sc == -1 );
|
||||
assert( errno == EAGAIN );
|
||||
|
||||
puts( "Init - sleep - let thread report if it unblocked - OK" );
|
||||
usleep(500000);
|
||||
|
||||
/* we are just sigwait'ing the signal, not delivering it */
|
||||
assert( Signal_occurred == true );
|
||||
|
||||
puts( "*** END OF POSIX TEST SIGNAL 03 ***" );
|
||||
rtems_test_exit(0);
|
||||
|
||||
return NULL; /* just so the compiler thinks we returned something */
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 3
|
||||
#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 1
|
||||
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#include <rtems/confdefs.h>
|
||||
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# COPYRIGHT (c) 1989-2009.
|
||||
# On-Line Applications Research Corporation (OAR).
|
||||
#
|
||||
# The license and distribution terms for this file may be
|
||||
# found in the file LICENSE in this distribution or at
|
||||
# http://www.rtems.com/license/LICENSE.
|
||||
#
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: psxsignal03
|
||||
|
||||
directives:
|
||||
|
||||
sigemptyset
|
||||
sigaddset
|
||||
pthread_sigmask
|
||||
sigwaitinfo
|
||||
sigaction
|
||||
pthread_create
|
||||
kill
|
||||
kill
|
||||
|
||||
concepts:
|
||||
|
||||
+ Ensure the the algorithm in killinfo.c which decides which
|
||||
thread waiting on a signal is given a process wide signal to
|
||||
dispatch.
|
||||
@@ -0,0 +1,17 @@
|
||||
*** POSIX TEST SIGNAL 03 ***
|
||||
Init - sleep - let threads settle - OK
|
||||
SignalNotBlocked - Unblock SIGUSR1
|
||||
SignalNotBlocked - Unblock SIGUSR2
|
||||
SignalNotBlocked - Wait for SIGUSR1 unblocked
|
||||
SignalBlocked - Unblock SIGUSR1
|
||||
SignalBlocked - Wait for SIGUSR1 unblocked
|
||||
Init - sleep - SignalBlocked thread settle - OK
|
||||
Init - sending SIGUSR2 - deliver to one thread
|
||||
Init - sending SIGUSR2 - deliver to other thread
|
||||
Init - sending SIGUSR2 - expect EAGAIN
|
||||
Init - sleep - let thread report if it unblocked - OK
|
||||
SignalNotBlocked - siginfo.si_signo=26
|
||||
SignalNotBlocked - siginfo.si_code=1
|
||||
SignalNotBlocked - siginfo.si_value=0x02034474
|
||||
SignalNotBlocked - exiting
|
||||
*** END OF POSIX TEST SIGNAL 03 ***
|
||||
Reference in New Issue
Block a user