source: rtems/testsuites/psxtmtests/psxtmbarrier01/init.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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