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

Last change on this file was 96e4b22, checked in by Chris Johns <chrisj@…>, on Mar 6, 2019 at 9:39:29 AM

testsuite: Make the OPERATION_COUNT a test configuration parameter.

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