source: rtems/testsuites/psxtmtests/psxtmrwlock04/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.9 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
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13#include <coverhd.h>
14#include <errno.h>
15#include <timesys.h>
16#include <tmacros.h>
17#include <sched.h>
18#include <pthread.h>
19#include <rtems/timerdrv.h>
20#include "test_support.h"
21
22pthread_rwlock_t     rwlock;
23
24void *Low(
25  void *argument
26)
27{
28  benchmark_timer_t end_time;
29
30  /*
31   * Now we have finished the thread startup overhead,
32   * so let other threads run.  When we return, we can
33   * finish the benchmark.
34   */
35  sched_yield();
36    /* let other threads run */
37
38  end_time = benchmark_timer_read();
39
40  put_time(
41    "pthread_rwlock_wrlock - not available, blocks",
42    end_time,
43    OPERATION_COUNT,
44    0,
45    0
46  );
47
48  puts( "*** END OF POSIX TIME PSXTMRWLOCK 04 TEST ***" );
49
50  rtems_test_exit( 0 );
51  return NULL;
52}
53
54void *Middle(
55  void *argument
56)
57{
58  int status;
59
60  /*
61   * Now we have finished the thread startup overhead,
62   * so let other threads run.  When we return, we can
63   * finish the benchmark.
64   */
65  sched_yield();
66    /* let other threads run */
67
68  /* this write lock operation will be blocked
69   * cause another write operation has the lock */
70    status = pthread_rwlock_wrlock(&rwlock);
71  rtems_test_assert( status == 0 );
72  return NULL;
73}
74
75void *POSIX_Init(
76  void *argument
77)
78{
79  int        i;
80  int        status;
81  pthread_t  threadId;
82  pthread_rwlockattr_t attr;
83
84  puts( "\n\n*** POSIX TIME PSXTMRWLOCK 04 TEST ***" );
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 rwlock after the threads.  This way if the
96   * threads do run before we intend, they will get an error.
97   */
98  status = pthread_rwlockattr_init( &attr );
99  rtems_test_assert( status == 0 );
100    status = pthread_rwlock_init( &rwlock, &attr );
101  rtems_test_assert( status == 0 );
102  /*
103   * Let the other threads start so the thread startup overhead,
104   * is accounted for.  When we return, we can start the benchmark.
105   */
106  sched_yield();
107    /* let other threads run */
108 
109  /* start the timer and switch through all the other tasks */
110  benchmark_timer_initialize();
111  /* write lock operation */
112    status = pthread_rwlock_wrlock(&rwlock);
113  rtems_test_assert( status == 0 );
114  return NULL;
115}
116
117/* configuration information */
118
119#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
120#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
121
122#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
123#define CONFIGURE_MAXIMUM_POSIX_RWLOCKS     1
124#define CONFIGURE_POSIX_INIT_THREAD_TABLE
125
126#define CONFIGURE_INIT
127
128#include <rtems/confdefs.h>
129/* end of file */
Note: See TracBrowser for help on using the repository browser.