source: rtems/testsuites/psxtmtests/psxtmmutex04/init.c @ 88d965b6

4.115
Last change on this file since 88d965b6 was 88d965b6, checked in by Joel Sherrill <joel.sherrill@…>, on 07/21/11 at 13:48:52

2011-07-21 Ricardo Aguirre <el.mastin@…>

PR 1835/tests

  • Makefile.am, configure.ac: Add benchmark of pthread_mutex_timedlock - not available, block.
  • psxtmmutex04/.cvsignore, psxtmmutex04/Makefile.am, psxtmmutex04/init.c, psxtmmutex04/psxtmmutex04.doc: New files.
  • Property mode set to 100644
File size: 2.7 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 <timesys.h>
17#include <tmacros.h>
18#include <rtems/timerdrv.h>
19#include "test_support.h"
20
21#include <pthread.h>
22#include <sched.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_timedlock - not available, block",
44    end_time,
45    OPERATION_COUNT,
46    0,
47    0
48  );
49
50  puts( "*** END OF POSIX TIME TEST PSXTMMUTEX04 ***" );
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 );  /*this is important*/
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 PSXTMMUTEX04 ***" );
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_timedlock( &MutexId, 0 );
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.