diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-07-31 16:17:02 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-07-31 16:17:02 +0000 |
commit | e6e75e20f76c6302bcb4fc3572c00873a464283f (patch) | |
tree | 194fe84b40c35edfaada406f29da8eaf46cc9769 /testsuites/psxtests/psx16/init.c | |
parent | 2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff) | |
download | rtems-e6e75e20f76c6302bcb4fc3572c00873a464283f.tar.bz2 |
2011-07-31 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1867/cpukit
* Makefile.am, configure.ac, psx12/task.c, psxrwlock01/test.c: Correct
implementation of pthread_exit() and pthread_join() to support the
case where a thread is joinable but calls pthread_exit() before a
thread has attempted to join.
* psx16/.cvsignore, psx16/Makefile.am, psx16/init.c, psx16/psx16.doc,
psx16/psx16.scn: New files.
Diffstat (limited to 'testsuites/psxtests/psx16/init.c')
-rw-r--r-- | testsuites/psxtests/psx16/init.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/testsuites/psxtests/psx16/init.c b/testsuites/psxtests/psx16/init.c new file mode 100644 index 0000000000..c829d9aadd --- /dev/null +++ b/testsuites/psxtests/psx16/init.c @@ -0,0 +1,78 @@ +/* + * COPYRIGHT (c) 1989-2011. + * 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 <tmacros.h> +#include "test_support.h" +#include <pthread.h> + +int Index; + +void *TestThread( + void *argument +) +{ + int *index = (int *)argument; + + *index = 7; + + puts( "TestThread exiting" ); + return argument; +} + +void *POSIX_Init( + rtems_task_argument argument +) +{ + int status; + pthread_t id; + pthread_attr_t attr; + void *join_return; + + puts( "\n\n*** POSIX TEST PSX16 ***" ); + + Index = 5; + + /* Initialize and set thread detached attribute */ + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + + puts( "Creating TestThread" ); + status = pthread_create( &id, &attr, TestThread, (void *)&Index ); + rtems_test_assert( status == 0 ); + + /* let test thread run and exit */ + puts( "Let TestThread run and exit before we attempt to join" ); + sleep( 2 ); + + join_return = NULL; + status = pthread_join( id, &join_return ); + rtems_test_assert( status == 0 ); + rtems_test_assert( join_return == &Index ); + rtems_test_assert( *(int *)join_return == 7 ); + puts( "Successfully joined with TestThread" ); + + puts( "*** END OF POSIX TEST PSX16 ***" ); + + rtems_test_exit(0); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_INIT +#include <rtems/confdefs.h> +/* end of file */ |