source: rtems/testsuites/psxtmtests/psxtmrwlock06/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.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#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <coverhd.h>
15#include <pthread.h>
16#include <sched.h>
17#include <tmacros.h>
18#include <timesys.h>
19#include "test_support.h"
20#include <rtems/btimer.h>
21
22const char rtems_test_name[] = "PSXTMRWLOCK 06";
23
24/* forward declarations to avoid warnings */
25void *POSIX_Init(void *argument);
26void *Blocker(void *argument);
27
28pthread_rwlock_t     rwlock;
29
30void *Blocker(
31  void *argument
32)
33{
34  (void) pthread_rwlock_wrlock(&rwlock);
35  /* should never return */
36  rtems_test_assert( FALSE );
37
38  return NULL;
39}
40
41void *POSIX_Init(
42  void *argument
43)
44{
45  int                   status;
46  pthread_t             threadId;
47  benchmark_timer_t end_time;
48  pthread_rwlockattr_t  attr;
49
50  TEST_BEGIN();
51
52  status = pthread_create( &threadId, NULL, Blocker, NULL );
53  rtems_test_assert( status == 0 );
54  /*
55   * Deliberately create the rwlock after the threads.  This way if the
56   * threads do run before we intend, they will get an error.
57   */
58
59  /* creating rwlock */
60    status = pthread_rwlockattr_init( &attr );
61  rtems_test_assert( status == 0 );
62  status = pthread_rwlock_init( &rwlock, &attr );
63  rtems_test_assert( status == 0 );
64
65  /*
66   * Ensure the rwlock is unavailable so the other threads block.
67   */
68  /* lock rwlock to ensure thread blocks */
69  status = pthread_rwlock_wrlock(&rwlock);
70  rtems_test_assert( status == 0 );
71
72  /*
73   * Let the other thread start so the thread startup overhead,
74   * is accounted for.  When we return, we can start the benchmark.
75   */
76  sched_yield();
77    /* let other thread run */
78
79  benchmark_timer_initialize();
80    status = pthread_rwlock_unlock(&rwlock); /*  unlock the rwlock */
81  end_time = benchmark_timer_read();
82  rtems_test_assert( status == 0 );
83
84  put_time(
85    "pthread_rwlock_unlock: thread waiting 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_CONSOLE_DRIVER
101#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
102
103#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
104#define CONFIGURE_MAXIMUM_POSIX_RWLOCKS     1
105#define CONFIGURE_POSIX_INIT_THREAD_TABLE
106
107#define CONFIGURE_INIT
108
109#include <rtems/confdefs.h>
110  /* end of file */
Note: See TracBrowser for help on using the repository browser.