File indexing completed on 2025-05-11 08:24:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifdef HAVE_CONFIG_H
0028 #include "config.h"
0029 #endif
0030
0031 #include <timesys.h>
0032 #include <rtems/btimer.h>
0033 #include <errno.h>
0034 #include <pthread.h>
0035 #include "test_support.h"
0036
0037 const char rtems_test_name[] = "PSXTMKEY 02";
0038
0039
0040 void *POSIX_Init(void *argument);
0041 void benchmark_pthread_setspecific(void *value_p);
0042 void benchmark_pthread_getspecific( void *expected );
0043
0044 pthread_key_t Key;
0045 int Value1;
0046
0047 void benchmark_pthread_setspecific( void *value_p )
0048 {
0049 benchmark_timer_t end_time;
0050 int status;
0051
0052 benchmark_timer_initialize();
0053 status = pthread_setspecific( Key, value_p );
0054 end_time = benchmark_timer_read();
0055 rtems_test_assert( status == 0 );
0056
0057 put_time(
0058 "pthread_setspecific: only case: only case",
0059 end_time,
0060 1,
0061 0,
0062 0
0063 );
0064
0065 }
0066
0067 void benchmark_pthread_getspecific( void *expected )
0068 {
0069 benchmark_timer_t end_time;
0070 void *value_p;
0071
0072 benchmark_timer_initialize();
0073 value_p = pthread_getspecific( Key );
0074 end_time = benchmark_timer_read();
0075 rtems_test_assert( value_p == expected );
0076
0077 put_time(
0078 "pthread_getspecific: only case",
0079 end_time,
0080 1,
0081 0,
0082 0
0083 );
0084 }
0085
0086 void *POSIX_Init(
0087 void *argument
0088 )
0089 {
0090 int status;
0091
0092 TEST_BEGIN();
0093
0094
0095 status = pthread_key_create( &Key, NULL );
0096 rtems_test_assert( status == 0 );
0097
0098 benchmark_pthread_getspecific( NULL );
0099 benchmark_pthread_setspecific( &Value1 );
0100 benchmark_pthread_getspecific( &Value1 );
0101
0102
0103 status = pthread_key_delete( Key );
0104 rtems_test_assert( status == 0 );
0105
0106 TEST_END();
0107 rtems_test_exit(0);
0108 }
0109
0110
0111
0112 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0113 #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
0114
0115 #define CONFIGURE_MAXIMUM_POSIX_THREADS 2
0116 #define CONFIGURE_MAXIMUM_POSIX_KEYS 1
0117 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
0118
0119 #define CONFIGURE_INIT
0120 #include <rtems/confdefs.h>
0121