1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2013. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <timesys.h> |
---|
15 | #include <rtems/btimer.h> |
---|
16 | #include <errno.h> |
---|
17 | #include <pthread.h> |
---|
18 | #include "test_support.h" |
---|
19 | |
---|
20 | const char rtems_test_name[] = "PSXTMKEY 01"; |
---|
21 | |
---|
22 | /* forward declarations to avoid warnings */ |
---|
23 | void *POSIX_Init(void *argument); |
---|
24 | |
---|
25 | pthread_key_t Key; |
---|
26 | |
---|
27 | static void benchmark_pthread_key_create(void) |
---|
28 | { |
---|
29 | benchmark_timer_t end_time; |
---|
30 | int status; |
---|
31 | |
---|
32 | benchmark_timer_initialize(); |
---|
33 | status = pthread_key_create(&Key, NULL); |
---|
34 | end_time = benchmark_timer_read(); |
---|
35 | rtems_test_assert( status == 0 ); |
---|
36 | |
---|
37 | put_time( |
---|
38 | "pthread_key_create: only case", |
---|
39 | end_time, |
---|
40 | 1, /* Only executed once */ |
---|
41 | 0, |
---|
42 | 0 |
---|
43 | ); |
---|
44 | |
---|
45 | } |
---|
46 | |
---|
47 | static void benchmark_pthread_key_delete(void) |
---|
48 | { |
---|
49 | benchmark_timer_t end_time; |
---|
50 | int status; |
---|
51 | |
---|
52 | benchmark_timer_initialize(); |
---|
53 | status = pthread_key_delete(Key); |
---|
54 | end_time = benchmark_timer_read(); |
---|
55 | rtems_test_assert( status == 0 ); |
---|
56 | |
---|
57 | put_time( |
---|
58 | "pthread_key_delete: only case", |
---|
59 | end_time, |
---|
60 | 1, /* Only executed once */ |
---|
61 | 0, |
---|
62 | 0 |
---|
63 | ); |
---|
64 | |
---|
65 | } |
---|
66 | |
---|
67 | void *POSIX_Init(void *argument) |
---|
68 | { |
---|
69 | |
---|
70 | TEST_BEGIN(); |
---|
71 | |
---|
72 | /*key creation, using NULL destructor*/ |
---|
73 | benchmark_pthread_key_create(); |
---|
74 | |
---|
75 | /* key deletion*/ |
---|
76 | benchmark_pthread_key_delete(); |
---|
77 | |
---|
78 | TEST_END(); |
---|
79 | |
---|
80 | rtems_test_exit(0); |
---|
81 | } |
---|
82 | |
---|
83 | /* configuration information */ |
---|
84 | |
---|
85 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
86 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
87 | |
---|
88 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 2 |
---|
89 | #define CONFIGURE_MAXIMUM_POSIX_KEYS 1 |
---|
90 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
91 | |
---|
92 | #define CONFIGURE_INIT |
---|
93 | |
---|
94 | #include <rtems/confdefs.h> |
---|
95 | /* end of file */ |
---|