source: rtems/testsuites/psxtmtests/psxtmbarrier02/init.c @ 991a3cc1

4.115
Last change on this file since 991a3cc1 was 991a3cc1, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/12 at 14:15:40

psxtmtests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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 <timesys.h>
15#include <tmacros.h>
16#include <rtems/timerdrv.h>
17#include "test_support.h"
18
19#include <pthread.h>
20#include <sched.h>
21
22/* forward declarations to avoid warnings */
23void *POSIX_Init(void *argument);
24void *Middle(void *argument);
25void *Low(void *argument);
26
27pthread_barrier_t     barrier;
28
29void *Low(
30  void *argument
31)
32{
33  benchmark_timer_t end_time;
34
35  /*
36   * Now we have finished the thread startup overhead,
37   * so let other threads run.  When we return, we can
38   * finish the benchmark.
39   */
40  sched_yield();
41    /* let other threads run */
42
43  end_time = benchmark_timer_read();
44
45  put_time(
46    "pthread_barrier_wait – blocking",
47    end_time,
48    OPERATION_COUNT,
49    0,
50    0
51  );
52
53  puts( "*** END OF POSIX TIME PSXTMBARRIER 02 ***" );
54
55  rtems_test_exit( 0 );
56  return NULL;
57}
58
59void *Middle(
60  void *argument
61)
62{
63  /*
64   * Now we have finished the thread startup overhead,
65   * so let other threads run.  When we return, we can
66   * finish the benchmark.
67   */
68  sched_yield();
69    /* let other threads run */
70
71    (void) pthread_barrier_wait( &barrier );
72 
73  /* should never return */
74  rtems_test_assert( FALSE );
75  return NULL;
76}
77
78void *POSIX_Init(
79  void *argument
80)
81{
82  int        i;
83  int        status;
84  pthread_t  threadId;
85  pthread_barrierattr_t attr;
86
87  puts( "\n\n*** POSIX TIME PSXTMBARRIER 02 ***" );
88
89  for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
90    status = pthread_create( &threadId, NULL, Middle, NULL );
91    rtems_test_assert( !status );
92  }
93 
94  status = pthread_create( &threadId, NULL, Low, NULL );
95  rtems_test_assert( !status );
96
97  /*
98   * Create the barrier with default attributes and deliberately
99   * create it after the Threads so if they run too early, they
100   * wull fail with an error.
101   */
102  status = pthread_barrierattr_init( &attr );
103  rtems_test_assert( status == 0 );
104
105  /*
106   * Set threshold on count higher than number of threads so all will
107   * block.
108   */
109  status = pthread_barrier_init( &barrier,&attr, OPERATION_COUNT + 2 );
110  rtems_test_assert( status == 0 );
111
112  /*
113   * Let other threads run through their initialization
114   */
115  sched_yield();
116
117  /*
118   * Start the timer and start the blocking barrier wait chain through
119   * all the other tasks.
120   */
121  benchmark_timer_initialize();
122    /* blocking barrier call */
123    status = pthread_barrier_wait( &barrier );
124  rtems_test_assert( status == 0 );
125  return NULL;
126}
127
128/* configuration information */
129
130#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
131#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
132
133#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
134#define CONFIGURE_MAXIMUM_POSIX_BARRIERS    1
135#define CONFIGURE_POSIX_INIT_THREAD_TABLE
136
137#define CONFIGURE_INIT
138
139#include <rtems/confdefs.h>
140  /* end of file */
Note: See TracBrowser for help on using the repository browser.