summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxkey06
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-03-04 15:54:12 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-03-07 13:21:11 -0600
commite6c87f78724743bc74a38678f93ed579ace840f2 (patch)
treedce3962edb00574dade0c8caf837cd85b9607831 /testsuites/psxtests/psxkey06
parentRemove trailing whitespace in previous patches (diff)
downloadrtems-e6c87f78724743bc74a38678f93ed579ace840f2.tar.bz2
POSIX keys now enabled in all configurations.
Formerly POSIX keys were only enabled when POSIX threads were enabled. Because they are a truly safe alternative to per-task variables in an SMP system, they are being enabled in all configurations.
Diffstat (limited to 'testsuites/psxtests/psxkey06')
-rw-r--r--testsuites/psxtests/psxkey06/init.c78
1 files changed, 43 insertions, 35 deletions
diff --git a/testsuites/psxtests/psxkey06/init.c b/testsuites/psxtests/psxkey06/init.c
index 98b46a42be..baf07cc81c 100644
--- a/testsuites/psxtests/psxkey06/init.c
+++ b/testsuites/psxtests/psxkey06/init.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012 Zhongwei Yao.
- * COPYRIGHT (c) 1989-2012.
+ * COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -18,25 +18,19 @@
#include "pmacros.h"
/* forward declarations to avoid warnings */
-void *POSIX_Init(void *argument);
-void *Test_Thread1(void *argument);
-void *Test_Thread2(void *argument);
+rtems_task Init(rtems_task_argument argument);
+rtems_task Test_Thread1(rtems_task_argument argument);
+rtems_task Test_Thread2(rtems_task_argument argument);
int Data_array[4] = {1, 2, 3, 4};
pthread_key_t key1, key2;
-void *Test_Thread1(
- void *argument
-)
+rtems_task Test_Thread1( rtems_task_argument argument )
{
int sc;
int *value;
struct timespec delay_request;
- /*
- * Detach ourselves so we don't wait for a join that won't happen.
- */
- pthread_detach( pthread_self() );
puts( "Test_Thread 1 - key1 pthread_setspecific - OK" );
sc = pthread_setspecific( key1, &Data_array[0] );
@@ -60,19 +54,13 @@ void *Test_Thread1(
value = pthread_getspecific( key2 );
rtems_test_assert( *value == Data_array[1] );
- return NULL;
+ rtems_task_delete( RTEMS_SELF );
}
-void *Test_Thread2(
- void *argument
-)
+rtems_task Test_Thread2( rtems_task_argument argument )
{
int sc;
int *value;
- /*
- * Detach ourselves so we don't wait for a join that won't happen.
- */
- pthread_detach( pthread_self() );
puts( "Test_Thread 2 - key1 pthread_setspecific - OK" );
sc = pthread_setspecific( key1, &Data_array[2] );
@@ -90,16 +78,16 @@ void *Test_Thread2(
value = pthread_getspecific( key2 );
rtems_test_assert( *value == Data_array[3] );
- return NULL;
+ rtems_task_delete( RTEMS_SELF );
}
-void *POSIX_Init(
- void *ignored
-)
+rtems_task Init( rtems_task_argument ignored )
{
- pthread_t thread1, thread2;
- int sc;
- struct timespec delay_request;
+ rtems_id thread1;
+ rtems_id thread2;
+ rtems_status_code rc;
+ int sc;
+ struct timespec delay_request;
puts( "\n\n*** TEST KEY 06 ***" );
@@ -111,13 +99,33 @@ void *POSIX_Init(
sc = pthread_key_create( &key2, NULL );
rtems_test_assert( !sc );
- puts( "Init - pthread1 create - OK" );
- sc = pthread_create( &thread1, NULL, Test_Thread1, NULL );
- rtems_test_assert( !sc );
-
- puts( "Init - pthread2 create - OK" );
- sc = pthread_create( &thread2, NULL, Test_Thread2, NULL );
- rtems_test_assert( !sc );
+ puts( "Init - thread1 create - OK" );
+ rc = rtems_task_create(
+ rtems_build_name( 'T', 'E', 'S', 'T' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &thread1
+ );
+ rtems_test_assert( rc == RTEMS_SUCCESSFUL );
+
+ rc = rtems_task_start( thread1, Test_Thread1, 0 );
+ rtems_test_assert( rc == RTEMS_SUCCESSFUL );
+
+ puts( "Init - thread2 create - OK" );
+ rc = rtems_task_create(
+ rtems_build_name( 'T', 'E', 'S', 'T' ),
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &thread2
+ );
+ rtems_test_assert( rc == RTEMS_SUCCESSFUL );
+
+ rc = rtems_task_start( thread2, Test_Thread2, 0 );
+ rtems_test_assert( rc == RTEMS_SUCCESSFUL );
puts( "Init - sleep - let thread run - OK" );
delay_request.tv_sec = 0;
@@ -142,10 +150,10 @@ void *POSIX_Init(
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
-#define CONFIGURE_MAXIMUM_POSIX_THREADS 3
+#define CONFIGURE_MAXIMUM_TASKS 3
#define CONFIGURE_MAXIMUM_POSIX_KEYS 2
-#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>