From e6c87f78724743bc74a38678f93ed579ace840f2 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 4 Mar 2014 15:54:12 -0600 Subject: 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. --- testsuites/psxtests/psxkey08/init.c | 95 ++++++++++++++++++------------- testsuites/psxtests/psxkey08/psxkey08.scn | 7 ++- 2 files changed, 58 insertions(+), 44 deletions(-) (limited to 'testsuites/psxtests/psxkey08') diff --git a/testsuites/psxtests/psxkey08/init.c b/testsuites/psxtests/psxkey08/init.c index 81f4378828..2c74d23c18 100644 --- a/testsuites/psxtests/psxkey08/init.c +++ b/testsuites/psxtests/psxkey08/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 @@ -36,7 +36,6 @@ rtems_task test_task(rtems_task_argument arg) int *value_p, *value_p2; value_p = malloc( sizeof( int ) ); - //printf( "Test_Task%d - Key pthread_setspecific - OK\n", (int)rtems_task_self() ); sc = pthread_setspecific( Key, value_p ); rtems_test_assert( !sc ); ++setted_task_count; @@ -47,12 +46,11 @@ rtems_task test_task(rtems_task_argument arg) */ rtems_semaphore_obtain( sema2 , RTEMS_WAIT, 0 ); - //printf( "Test_Task%d - Key pthread_getspecific - OK\n", (int)rtems_task_self() ); value_p2 = pthread_getspecific( Key ); rtems_test_assert( value_p == value_p2 ); ++got_task_count; - pthread_exit( 0 ); + rtems_task_delete( RTEMS_SELF ); } rtems_task Init(rtems_task_argument arg) @@ -67,54 +65,69 @@ rtems_task Init(rtems_task_argument arg) puts( "Init - Semaphore 1 create - OK" ); name1 = rtems_build_name('S', 'E', 'M', '1'); - sc = rtems_semaphore_create( name1, 0, - RTEMS_SIMPLE_BINARY_SEMAPHORE | - RTEMS_FIFO, - 0, &sema1 ); + sc = rtems_semaphore_create( + name1, 0, + RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO, + 0, + &sema1 + ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); puts( "Init - Semaphore 2 create - OK" ); name2 = rtems_build_name('S', 'E', 'M', '2'); - sc = rtems_semaphore_create( name2, 0, - RTEMS_SIMPLE_BINARY_SEMAPHORE | - RTEMS_FIFO, - 0, &sema2 ); + sc = rtems_semaphore_create( + name2, + 0, + RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO, + 0, + &sema2 + ); rtems_test_assert( sc == RTEMS_SUCCESSFUL ); puts( "Init - pthread Key create - OK" ); sc = pthread_key_create( &Key, NULL ); rtems_test_assert( !sc ); - for( ; ; ) - { - task_id_p = malloc( sizeof( rtems_id ) ); - rtems_test_assert( task_id_p ); - sc = rtems_task_create( - rtems_build_name('T','A',created_task_count, ' '), - 1, - RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, - task_id_p - ); - rtems_test_assert( (sc == RTEMS_UNSATISFIED) || (sc == RTEMS_TOO_MANY) || (sc == RTEMS_SUCCESSFUL) ); - /** - * when return is RTEMS_TOO_MANY or RTEMS_UNSATISFIED, there is not - * enough source to create task. - */ - if ( (sc == RTEMS_TOO_MANY) || (sc == RTEMS_UNSATISFIED) ) - { - break; - } - ++created_task_count; - sc = rtems_task_start( *task_id_p, test_task, 0 ); - rtems_test_assert( sc == RTEMS_SUCCESSFUL ); - sc = rtems_semaphore_obtain( sema1, RTEMS_WAIT, 0 ); - rtems_test_assert( sc == RTEMS_SUCCESSFUL ); + for ( ; ; ) { + task_id_p = malloc( sizeof( rtems_id ) ); + rtems_test_assert( task_id_p ); + + sc = rtems_task_create( + rtems_build_name('T','A',created_task_count, ' '), + 1, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + task_id_p + ); + rtems_test_assert( + (sc == RTEMS_UNSATISFIED) || + (sc == RTEMS_TOO_MANY) || + (sc == RTEMS_SUCCESSFUL) + ); + + /** + * when return is RTEMS_TOO_MANY or RTEMS_UNSATISFIED, there is not + * enough source to create task. + */ + if ( (sc == RTEMS_TOO_MANY) || (sc == RTEMS_UNSATISFIED) ) { + break; } + ++created_task_count; - printf( "Init - %d tasks have been created - OK\n", created_task_count ); - printf( "Init - %d tasks have been setted key data - OK\n", setted_task_count ); + sc = rtems_task_start( *task_id_p, test_task, 0 ); + rtems_test_assert( sc == RTEMS_SUCCESSFUL ); + + sc = rtems_semaphore_obtain( sema1, RTEMS_WAIT, 0 ); + rtems_test_assert( sc == RTEMS_SUCCESSFUL ); + } + + printf( + "Init - %d tasks have been created - OK\n" + "Init - %d tasks have been setted key data - OK\n", + setted_task_count, + created_task_count + ); rtems_test_assert( created_task_count == setted_task_count ); /* unblock all created tasks to let them set key data.*/ @@ -146,7 +159,7 @@ rtems_task Init(rtems_task_argument arg) /* configuration information */ #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER #define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(5) #define CONFIGURE_MAXIMUM_SEMAPHORES 2 diff --git a/testsuites/psxtests/psxkey08/psxkey08.scn b/testsuites/psxtests/psxkey08/psxkey08.scn index a4f1be4959..64f23f8829 100644 --- a/testsuites/psxtests/psxkey08/psxkey08.scn +++ b/testsuites/psxtests/psxkey08/psxkey08.scn @@ -1,14 +1,15 @@ +sparc-rtems4.11-run is /home/joel/rtems-4.11-work/tools/bin/sparc-rtems4.11-run *** TEST KEY 08 *** Init - Semaphore 1 create - OK Init - Semaphore 2 create - OK Init - pthread Key create - OK -Init - 651 tasks have been created - OK -Init - 651 tasks have been setted key data - OK +Init - 720 tasks have been created - OK +Init - 720 tasks have been setted key data - OK Init - flush semaphore 2 - OK Init - sleep to yield processor - OK -Init - 651 Tasks have been got key data - OK +Init - 720 Tasks have been got key data - OK Init - pthread Key delete - OK Init - semaphore 1 delete - OK Init - semaphore 2 delete - OK -- cgit v1.2.3