source: rtems/testsuites/psxtmtests/psxtmmutex05/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.1 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
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/timerdrv.h>
21
22pthread_mutex_t MutexId;
23
24void *Blocker(
25  void *argument
26)
27{
28  (void) pthread_mutex_lock( &MutexId );
29  /* should never return */
30  rtems_test_assert( FALSE );
31
32  return NULL;
33}
34
35void *POSIX_Init(
36  void *argument
37)
38{
39  int        status;
40  pthread_t  threadId;
41  benchmark_timer_t end_time;
42
43  puts( "\n\n*** POSIX TIME TEST PSXTMMUTEX05 ***" );
44
45  status = pthread_create( &threadId, NULL, Blocker, NULL );
46  rtems_test_assert( status == 0 );
47 
48  /*
49   * Deliberately create the mutex after the threads.  This way if the
50   * threads do run before we intend, they will get an error.
51   */
52  status = pthread_mutex_init( &MutexId, NULL );
53  rtems_test_assert( status == 0 );
54
55  /*
56   * Ensure the mutex is unavailable so the other threads block.
57   */
58  status = pthread_mutex_lock( &MutexId );
59  rtems_test_assert( status == 0 );
60
61  /*
62   * Let the other thread start so the thread startup overhead,
63   * is accounted for.  When we return, we can start the benchmark.
64   */
65  sched_yield();
66    /* let other thread run */
67
68  benchmark_timer_initialize();
69    status = pthread_mutex_unlock( &MutexId );
70  end_time = benchmark_timer_read();
71  rtems_test_assert( status == 0 );
72
73  put_time(
74    "pthread_mutex_unlock - unblocking, no preemption",
75    end_time,
76    1,
77    0,
78    0
79  );
80
81  puts( "*** END OF POSIX TIME TEST PSXTMMUTEX05 ***" );
82  rtems_test_exit( 0 );
83
84  return NULL;
85}
86
87/* configuration information */
88
89#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
90#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
91
92#define CONFIGURE_MAXIMUM_POSIX_THREADS     2
93#define CONFIGURE_MAXIMUM_POSIX_MUTEXES     1
94#define CONFIGURE_POSIX_INIT_THREAD_TABLE
95
96#define CONFIGURE_INIT
97
98#include <rtems/confdefs.h>
99  /* end of file */
Note: See TracBrowser for help on using the repository browser.