source: rtems/testsuites/psxtmtests/psxtmbarrierattr01/init.c @ 69812aa

5
Last change on this file since 69812aa was 69812aa, checked in by Himanshu40 <himanshuwindows8.1@…>, on Nov 21, 2018 at 4:00:35 PM

psxtmbarrierattr01: Added new POSIX timing suite (GCI 2018)

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 2018.
3 *  Himanshu Sekhar Nayak( GCI 2018 )
4 *
5 *  Permission to use, copy, modify, and/or distribute this software
6 *  for any purpose with or without fee is hereby granted.
7 *
8 *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
9 *  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
10 *  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
11 *  BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
12 *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
13 *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
14 *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <pthread.h>
22#include <tmacros.h>
23#include <timesys.h>
24#include <rtems/btimer.h>
25#include "test_support.h"
26
27const char rtems_test_name[] = "PSXTMBARRIERATTR01";
28
29/* forward declarations to avoid warnings */
30static void *POSIX_Init(void *argument);
31
32static pthread_barrierattr_t attr;
33
34static void benchmark_create_barrierattr(void)
35{
36  long end_time;
37  int  status;
38
39  benchmark_timer_initialize();
40  status = pthread_barrierattr_init( &attr );
41  end_time = benchmark_timer_read();
42  rtems_test_assert( status == 0 );
43
44  put_time(
45    "pthread_barrierattr_init: only case",
46    end_time,
47    1,        /* Only executed once */
48    0,
49    0
50  );
51
52}
53
54static void benchmark_barrierattr_setpshared(void)
55{
56  long end_time;
57  int  status;
58
59  benchmark_timer_initialize();
60  status = pthread_barrierattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
61  end_time = benchmark_timer_read();
62  rtems_test_assert( status == 0 );
63
64  put_time(
65    "pthread_barrierattr_setpshared: only case",
66    end_time,
67    1,        /* Only executed once */
68    0,
69    0
70  );
71
72}
73
74static void benchmark_barrierattr_getpshared(void)
75{
76  long end_time;
77  int  status;
78  int pshared;
79
80  benchmark_timer_initialize();
81  status = pthread_barrierattr_getpshared( &attr, &pshared );
82  end_time = benchmark_timer_read();
83  rtems_test_assert( status == 0 );
84  rtems_test_assert( pshared == PTHREAD_PROCESS_SHARED );
85
86  put_time(
87    "pthread_barrierattr_getpshared: only case",
88    end_time,
89    1,        /* Only executed once */
90    0,
91    0
92  );
93
94}
95
96static void benchmark_destroy_barrierattr(void)
97{
98  long end_time;
99  int  status;
100
101  benchmark_timer_initialize();
102  status = pthread_barrierattr_destroy( &attr );
103  end_time = benchmark_timer_read();
104  rtems_test_assert( status == 0 );
105
106  put_time(
107    "pthread_barrierattr_destroy: only case",
108    end_time,
109    1,        /* Only executed once */
110    0,
111    0
112  );
113
114}
115
116static void *POSIX_Init(
117  void *argument
118)
119{
120
121  TEST_BEGIN();
122
123  benchmark_create_barrierattr();
124  benchmark_barrierattr_setpshared();
125  benchmark_barrierattr_getpshared();
126  benchmark_destroy_barrierattr();
127
128  TEST_END();
129  rtems_test_exit(0);
130}
131
132/* configuration information */
133
134#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
135#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
136
137#define CONFIGURE_MAXIMUM_POSIX_THREADS     1
138#define CONFIGURE_POSIX_INIT_THREAD_TABLE
139
140#define CONFIGURE_INIT
141
142#include <rtems/confdefs.h>
143/* end of file */
Note: See TracBrowser for help on using the repository browser.