1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2011. |
---|
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.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <coverhd.h> |
---|
17 | #include <tmacros.h> |
---|
18 | #include <timesys.h> |
---|
19 | #include "test_support.h" |
---|
20 | #include <pthread.h> |
---|
21 | #include <sched.h> |
---|
22 | #include <rtems/timerdrv.h> |
---|
23 | |
---|
24 | #define N 2 |
---|
25 | pthread_barrier_t barrier; |
---|
26 | |
---|
27 | void *Blocker( |
---|
28 | void *argument |
---|
29 | ) |
---|
30 | { |
---|
31 | (void) pthread_barrier_wait( &barrier ); |
---|
32 | rtems_test_assert( FALSE ); |
---|
33 | return NULL; |
---|
34 | } |
---|
35 | |
---|
36 | void *POSIX_Init( |
---|
37 | void *argument |
---|
38 | ) |
---|
39 | { |
---|
40 | int status; |
---|
41 | pthread_t threadId; |
---|
42 | benchmark_timer_t end_time; |
---|
43 | |
---|
44 | puts( "\n\n*** POSIX TIME TEST PSXTMBARRIER 03 ***" ); |
---|
45 | |
---|
46 | status = pthread_create( &threadId, NULL, Blocker, NULL ); |
---|
47 | rtems_test_assert( status == 0 ); |
---|
48 | |
---|
49 | /* |
---|
50 | * Deliberately create the barrier after the threads. This way if the |
---|
51 | * threads do run before we intend, they will get an error. |
---|
52 | * The barrier will be released on the Nth thread blocking. |
---|
53 | */ |
---|
54 | status = pthread_barrier_init( &barrier, NULL, N ); |
---|
55 | rtems_test_assert( status == 0 ); |
---|
56 | |
---|
57 | /* |
---|
58 | * Let the other thread start so the thread startup overhead, |
---|
59 | * is accounted for. When we return, we can start the benchmark. |
---|
60 | */ |
---|
61 | sched_yield(); |
---|
62 | /* let other thread run */ |
---|
63 | |
---|
64 | /* |
---|
65 | * Because this is the Nth thread at the barrier, this is an |
---|
66 | * unblocking operation. |
---|
67 | */ |
---|
68 | benchmark_timer_initialize(); |
---|
69 | status = pthread_barrier_wait( &barrier ); |
---|
70 | end_time = benchmark_timer_read(); |
---|
71 | /* |
---|
72 | * Upon successful completion return value, the status should be |
---|
73 | * PTHREAD_BARRIER_SERIAL_THREAD. |
---|
74 | */ |
---|
75 | rtems_test_assert( status == PTHREAD_BARRIER_SERIAL_THREAD ); |
---|
76 | |
---|
77 | put_time( |
---|
78 | "pthread_barrier_wait â releasing, no preempt", |
---|
79 | end_time, |
---|
80 | 1, |
---|
81 | 0, |
---|
82 | 0 |
---|
83 | ); |
---|
84 | |
---|
85 | puts( "*** END OF POSIX TIME TEST PSXTMBARRIER 03 ***" ); |
---|
86 | rtems_test_exit( 0 ); |
---|
87 | |
---|
88 | return NULL; |
---|
89 | } |
---|
90 | |
---|
91 | /* configuration information */ |
---|
92 | |
---|
93 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
94 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
95 | |
---|
96 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 2 |
---|
97 | #define CONFIGURE_MAXIMUM_POSIX_BARRIERS 1 |
---|
98 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
99 | |
---|
100 | #define CONFIGURE_INIT |
---|
101 | |
---|
102 | #include <rtems/confdefs.h> |
---|
103 | /* end of file */ |
---|