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

4.115
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/14 at 13:59:49

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.2 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[] = "PSXTMMUTEX 05";
23
24/* forward declarations to avoid warnings */
25void *POSIX_Init(void *argument);
26void *Blocker(void *argument);
27
28pthread_mutex_t MutexId;
29
30void *Blocker(
31  void *argument
32)
33{
34  (void) pthread_mutex_lock( &MutexId );
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
49  TEST_BEGIN();
50
51  status = pthread_create( &threadId, NULL, Blocker, NULL );
52  rtems_test_assert( status == 0 );
53 
54  /*
55   * Deliberately create the mutex after the threads.  This way if the
56   * threads do run before we intend, they will get an error.
57   */
58  status = pthread_mutex_init( &MutexId, NULL );
59  rtems_test_assert( status == 0 );
60
61  /*
62   * Ensure the mutex is unavailable so the other threads block.
63   */
64  status = pthread_mutex_lock( &MutexId );
65  rtems_test_assert( status == 0 );
66
67  /*
68   * Let the other thread start so the thread startup overhead,
69   * is accounted for.  When we return, we can start the benchmark.
70   */
71  sched_yield();
72    /* let other thread run */
73
74  benchmark_timer_initialize();
75    status = pthread_mutex_unlock( &MutexId );
76  end_time = benchmark_timer_read();
77  rtems_test_assert( status == 0 );
78
79  put_time(
80    "pthread_mutex_unlock: unblocking no preemption",
81    end_time,
82    1,
83    0,
84    0
85  );
86
87  TEST_END();
88  rtems_test_exit( 0 );
89
90  return NULL;
91}
92
93/* configuration information */
94
95#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
96#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
97
98#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
99#define CONFIGURE_MAXIMUM_POSIX_MUTEXES     1
100#define CONFIGURE_POSIX_INIT_THREAD_TABLE
101
102#define CONFIGURE_INIT
103
104#include <rtems/confdefs.h>
105  /* end of file */
Note: See TracBrowser for help on using the repository browser.