source: rtems/testsuites/psxtmtests/psxtmbarrier03/init.c @ 8fbe2e6

4.11
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2014 at 1:59:49 PM

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 2.3 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 <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/btimer.h>
21
22const char rtems_test_name[] = "PSXTMBARRIER 03";
23
24/* forward declarations to avoid warnings */
25void *POSIX_Init(void *argument);
26void *Blocker(void *argument);
27
28#define N  2
29pthread_barrier_t     barrier;
30
31void *Blocker(
32  void *argument
33)
34{
35  (void) pthread_barrier_wait( &barrier );
36  rtems_test_assert( FALSE );
37  return NULL;
38}
39
40void *POSIX_Init(
41  void *argument
42)
43{
44  int        status;
45  pthread_t  threadId;
46  benchmark_timer_t end_time;
47
48  TEST_BEGIN();
49
50  status = pthread_create( &threadId, NULL, Blocker, NULL );
51  rtems_test_assert( status == 0 );
52
53  /*
54   * Deliberately create the barrier after the threads.  This way if the
55   * threads do run before we intend, they will get an error.
56   * The barrier will be released on the Nth thread blocking.
57   */
58  status = pthread_barrier_init( &barrier, NULL, N );
59  rtems_test_assert( status == 0 );
60
61  /*
62   * Let the other thread start so the thread startup overhead,
63   * is accounted for.  When we return, we can start the benchmark.
64   */
65  sched_yield();
66    /* let other thread run */
67
68  /*
69   * Because this is the Nth thread at the barrier, this is an
70   * unblocking operation.
71   */
72  benchmark_timer_initialize();
73  status = pthread_barrier_wait( &barrier );
74  end_time = benchmark_timer_read();
75  /*
76   * Upon successful completion return value, the status should be
77   * PTHREAD_BARRIER_SERIAL_THREAD.
78   */
79  rtems_test_assert( status == PTHREAD_BARRIER_SERIAL_THREAD );
80
81  put_time(
82    "pthread_barrier_wait: releasing no preempt",
83    end_time,
84    1,
85    0,
86    0
87  );
88
89  TEST_END();
90  rtems_test_exit( 0 );
91
92  return NULL;
93}
94
95/* configuration information */
96
97#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
98#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
99
100#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
101#define CONFIGURE_MAXIMUM_POSIX_BARRIERS    1
102#define CONFIGURE_POSIX_INIT_THREAD_TABLE
103
104#define CONFIGURE_INIT
105
106#include <rtems/confdefs.h>
107/* end of file */
Note: See TracBrowser for help on using the repository browser.