source: rtems/testsuites/psxtmtests/psxtmonce01/init.c @ 9bb39516

Last change on this file since 9bb39516 was 9bb39516, checked in by Himanshu40 <himanshuwindows8.1@…>, on Nov 6, 2018 at 6:29:10 PM

psxtmonce01: New test written by Himanshu40 as part of GCI2018

  • Property mode set to 100644
File size: 1.9 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[] = "PSXTMONCE01";
28
29/* forward declarations to avoid warnings */
30void *POSIX_Init(void *argument);
31void benchmark_first_time(void);
32void initRoutine(void);
33
34pthread_once_t once_control = PTHREAD_ONCE_INIT;
35
36void initRoutine(void)
37{
38}
39
40void benchmark_first_time(void)
41{
42  long end_time;
43  int  status;
44
45  benchmark_timer_initialize();
46  status = pthread_once( &once_control, initRoutine );
47  end_time = benchmark_timer_read();
48  rtems_test_assert( status == 0 );
49
50  put_time(
51    "pthread_once: first time",
52    end_time,
53    1,        /* Only executed once */
54    0,
55    0
56  );
57}
58
59void *POSIX_Init(
60  void *argument
61)
62{
63
64  TEST_BEGIN();
65  benchmark_first_time();
66  TEST_END();
67
68  rtems_test_exit(0);
69}
70
71/* configuration information */
72
73#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
74#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
75
76#define CONFIGURE_MAXIMUM_POSIX_THREADS     1
77#define CONFIGURE_POSIX_INIT_THREAD_TABLE
78
79#define CONFIGURE_INIT
80
81#include <rtems/confdefs.h>
82/* end of file */
Note: See TracBrowser for help on using the repository browser.