source: rtems/testsuites/psxtmtests/psxtmsem03/init.c @ 991a3cc1

4.115
Last change on this file since 991a3cc1 was 991a3cc1, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/12 at 14:15:40

psxtmtests - Eliminate missing prototype warnings

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