source: rtems/testsuites/psxtmtests/psxtmbarrier03/init.c @ add2977

4.115
Last change on this file since add2977 was add2977, checked in by Ralf Corsepius <ralf.corsepius@…>, on Oct 19, 2011 at 3:27:27 PM

2011-10-19 Ralf Corsépius <ralf.corsepius@…>

  • psxtmbarrier01/init.c, psxtmbarrier02/init.c, psxtmbarrier03/init.c, psxtmkey01/init.c, psxtmkey02/init.c, psxtmmq01/init.c, psxtmmutex01/init.c, psxtmmutex02/init.c, psxtmmutex03/init.c, psxtmmutex04/init.c, psxtmmutex05/init.c, psxtmmutex06/init.c, psxtmmutex07/init.c, psxtmnanosleep01/init.c, psxtmnanosleep02/init.c, psxtmrwlock01/init.c, psxtmrwlock02/init.c, psxtmrwlock03/init.c, psxtmrwlock04/init.c, psxtmrwlock05/init.c, psxtmrwlock06/init.c, psxtmrwlock07/init.c, psxtmsem01/init.c, psxtmsem02/init.c, psxtmsem03/init.c, psxtmsem04/init.c, psxtmsem05/init.c, psxtmsleep01/init.c, psxtmsleep02/init.c, psxtmthread03/init.c: Use benchmark_timer_t for benchmark_timer values (Avoid 64bit arch issues).
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
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 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <coverhd.h>
17#include <tmacros.h>
18#include <timesys.h>
19#include "test_support.h"
20#include <pthread.h>
21#include <sched.h>
22#include <rtems/timerdrv.h>
23
24#define N  2
25pthread_barrier_t     barrier;
26
27void *Blocker(
28  void *argument
29)
30{
31  (void) pthread_barrier_wait( &barrier );
32  rtems_test_assert( FALSE );
33  return NULL;
34}
35
36void *POSIX_Init(
37  void *argument
38)
39{
40  int        status;
41  pthread_t  threadId;
42  benchmark_timer_t end_time;
43
44  puts( "\n\n*** POSIX TIME TEST PSXTMBARRIER 03 ***" );
45
46  status = pthread_create( &threadId, NULL, Blocker, NULL );
47  rtems_test_assert( status == 0 );
48
49  /*
50   * Deliberately create the barrier after the threads.  This way if the
51   * threads do run before we intend, they will get an error.
52   * The barrier will be released on the Nth thread blocking.
53   */
54  status = pthread_barrier_init( &barrier, NULL, N );
55  rtems_test_assert( status == 0 );
56
57  /*
58   * Let the other thread start so the thread startup overhead,
59   * is accounted for.  When we return, we can start the benchmark.
60   */
61  sched_yield();
62    /* let other thread run */
63
64  /*
65   * Because this is the Nth thread at the barrier, this is an
66   * unblocking operation.
67   */
68  benchmark_timer_initialize();
69    status = pthread_barrier_wait( &barrier );
70  end_time = benchmark_timer_read();
71  /*
72   * Upon successful completion return value, the status should be
73   * PTHREAD_BARRIER_SERIAL_THREAD.
74   */
75  rtems_test_assert( status == PTHREAD_BARRIER_SERIAL_THREAD );
76
77  put_time(
78    "pthread_barrier_wait – releasing, no preempt",
79    end_time,
80    1,
81    0,
82    0
83  );
84
85  puts( "*** END OF POSIX TIME TEST PSXTMBARRIER 03 ***" );
86  rtems_test_exit( 0 );
87
88  return NULL;
89}
90
91/* configuration information */
92
93#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
94#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
95
96#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
97#define CONFIGURE_MAXIMUM_POSIX_BARRIERS    1
98#define CONFIGURE_POSIX_INIT_THREAD_TABLE
99
100#define CONFIGURE_INIT
101
102#include <rtems/confdefs.h>
103/* end of file */
Note: See TracBrowser for help on using the repository browser.