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