source: rtems/testsuites/psxtmtests/psxtmmutex02/init.c @ e313551

4.11
Last change on this file since e313551 was e313551, checked in by Ralf Corsepius <ralf.corsepius@…>, on Feb 22, 2011 at 10:58:44 AM

Add HAVE_CONFIG_H.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2010.
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
24pthread_mutex_t MutexId;
25
26void *Low(
27  void *argument
28)
29{
30  uint32_t end_time;
31
32  /*
33   * Now we have finished the thread startup overhead,
34   * so let other threads run.  When we return, we can
35   * finish the benchmark.
36   */
37  sched_yield();
38    /* let other threads run */
39
40  end_time = benchmark_timer_read();
41
42  put_time(
43    "pthread_mutex_lock (unavailable)",
44    end_time,
45    OPERATION_COUNT,
46    0,
47    0
48  );
49
50  puts( "*** END OF POSIX TIME TEST MUTEX 02 ***" );
51
52  rtems_test_exit( 0 );
53  return NULL;
54}
55
56void *Middle(
57  void *argument
58)
59{
60  int status;
61
62  /*
63   * Now we have finished the thread startup overhead,
64   * so let other threads run.  When we return, we can
65   * finish the benchmark.
66   */
67  sched_yield();
68    /* let other threads run */
69
70  status = pthread_mutex_lock( &MutexId );
71  rtems_test_assert( !status );
72
73  return NULL;
74}
75
76void *POSIX_Init(
77  void *argument
78)
79{
80  int        i;
81  int        status;
82  pthread_t  threadId;
83
84  puts( "\n\n*** POSIX TIME TEST MUTEX 02 ***" );
85
86  for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
87    status = pthread_create( &threadId, NULL, Middle, NULL );
88    rtems_test_assert( !status );
89  }
90 
91  status = pthread_create( &threadId, NULL, Low, NULL );
92  rtems_test_assert( !status );
93
94  /*
95   * Deliberately create the mutex after the threads.  This way if the
96   * threads do run before we intend, they will get an error.
97   */
98  status = pthread_mutex_init( &MutexId, NULL );
99  rtems_test_assert( !status );
100
101  /*
102   * Let the other threads start so the thread startup overhead,
103   * is accounted for.  When we return, we can start the benchmark.
104   */
105  sched_yield();
106    /* let other threads run */
107
108  /* start the timer and switch through all the other tasks */
109  benchmark_timer_initialize();
110  status = pthread_mutex_lock( &MutexId );
111  rtems_test_assert( !status );
112
113  return NULL;
114}
115
116/* configuration information */
117
118#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
119#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
120
121#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
122#define CONFIGURE_MAXIMUM_POSIX_MUTEXES     1
123#define CONFIGURE_POSIX_INIT_THREAD_TABLE
124
125#define CONFIGURE_INIT
126
127#include <rtems/confdefs.h>
128  /* end of file */
Note: See TracBrowser for help on using the repository browser.