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 "test_support.h" |
---|
17 | #include <pthread.h> |
---|
18 | |
---|
19 | const char rtems_test_name[] = "PSXTMBARRIER 01"; |
---|
20 | |
---|
21 | /* forward declarations to avoid warnings */ |
---|
22 | void *POSIX_Init(void *argument); |
---|
23 | static void benchmark_pthread_barrier_init(void); |
---|
24 | |
---|
25 | pthread_barrier_t barrier; |
---|
26 | |
---|
27 | static void benchmark_pthread_barrier_init(void) |
---|
28 | { |
---|
29 | benchmark_timer_t end_time; |
---|
30 | int status; |
---|
31 | pthread_barrierattr_t attr; |
---|
32 | |
---|
33 | /* initialize attr with default attributes |
---|
34 | * for all of the attributes defined by the implementation |
---|
35 | */ |
---|
36 | status = pthread_barrierattr_init( &attr ); |
---|
37 | rtems_test_assert( status == 0 ); |
---|
38 | |
---|
39 | benchmark_timer_initialize(); |
---|
40 | status = pthread_barrier_init( &barrier,&attr, 1 ); |
---|
41 | end_time = benchmark_timer_read(); |
---|
42 | rtems_test_assert( status == 0 ); |
---|
43 | |
---|
44 | put_time( |
---|
45 | "pthread_barrier_init: only case", |
---|
46 | end_time, |
---|
47 | 1, /* Only executed once */ |
---|
48 | 0, |
---|
49 | 0 |
---|
50 | ); |
---|
51 | } |
---|
52 | |
---|
53 | static void benchmark_pthread_barrier_destroy(void) |
---|
54 | { |
---|
55 | benchmark_timer_t end_time; |
---|
56 | int status; |
---|
57 | |
---|
58 | benchmark_timer_initialize(); |
---|
59 | status = pthread_barrier_destroy( &barrier ); |
---|
60 | end_time = benchmark_timer_read(); |
---|
61 | rtems_test_assert( status == 0 ); |
---|
62 | |
---|
63 | put_time( |
---|
64 | "pthread_barrier_destroy: only case", |
---|
65 | end_time, |
---|
66 | 1, /* Only executed once */ |
---|
67 | 0, |
---|
68 | 0 |
---|
69 | ); |
---|
70 | } |
---|
71 | |
---|
72 | void *POSIX_Init( |
---|
73 | void *argument |
---|
74 | ) |
---|
75 | { |
---|
76 | TEST_BEGIN(); |
---|
77 | |
---|
78 | /* creating barrier with default properties */ |
---|
79 | benchmark_pthread_barrier_init(); |
---|
80 | /* destroying barrier */ |
---|
81 | benchmark_pthread_barrier_destroy(); |
---|
82 | |
---|
83 | TEST_END(); |
---|
84 | |
---|
85 | rtems_test_exit(0); |
---|
86 | } |
---|
87 | |
---|
88 | /* configuration information */ |
---|
89 | |
---|
90 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
91 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
92 | |
---|
93 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 |
---|
94 | #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 1 |
---|
95 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
96 | |
---|
97 | #define CONFIGURE_INIT |
---|
98 | |
---|
99 | #include <rtems/confdefs.h> |
---|
100 | /* end of file */ |
---|