diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-03-04 15:54:12 -0600 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-03-07 13:21:11 -0600 |
commit | e6c87f78724743bc74a38678f93ed579ace840f2 (patch) | |
tree | dce3962edb00574dade0c8caf837cd85b9607831 /testsuites/psxtests/psxkey08/init.c | |
parent | Remove trailing whitespace in previous patches (diff) | |
download | rtems-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/psxkey08/init.c')
-rw-r--r-- | testsuites/psxtests/psxkey08/init.c | 95 |
1 files changed, 54 insertions, 41 deletions
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 |