source: rtems/testsuites/psxtmtests/psxtmthread03/init.c @ 2ead50a

4.115
Last change on this file since 2ead50a was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
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.org/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
22/* forward declarations to avoid warnings */
23void *POSIX_Init(void *argument);
24void *Middle(void *argument);
25void *Low(void *argument);
26
27void *Low(
28  void *argument
29)
30{
31  benchmark_timer_t end_time;
32
33  /*
34   * Now we have finished the thread startup overhead,
35   * so let other threads run.  When we return, we can
36   * finish the benchmark.
37   */
38  sched_yield();
39    /* let other threads run */
40
41  end_time = benchmark_timer_read();
42
43  put_time(
44    "pthread_exit: only case",
45    end_time,
46    OPERATION_COUNT,
47    0,
48    0
49  );
50
51  puts( "*** END OF POSIX TIME TEST PSXTMTHREAD03 ***" );
52  rtems_test_exit( 0 );
53  return NULL;
54}
55
56void *Middle(
57  void *argument
58)
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  pthread_exit( NULL );
69  return NULL;
70}
71
72void *POSIX_Init(
73  void *argument
74)
75{
76  int        i;
77  int        status;
78  pthread_t  threadId;
79
80  puts( "\n\n*** POSIX TIME TEST PSXTMTHREAD03 ***" );
81
82  for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
83    status = pthread_create( &threadId, NULL, Middle, NULL );
84    rtems_test_assert( !status );
85  }
86 
87  status = pthread_create( &threadId, NULL, Low, NULL );
88  rtems_test_assert( !status );
89
90  /*
91   * Let the other threads start so the thread startup overhead,
92   * is accounted for.  When we return, we can start the benchmark.
93   */
94  sched_yield();
95    /* let other threads run */
96
97  /* start the timer and switch through all the other tasks */
98  benchmark_timer_initialize();
99  pthread_exit( NULL );
100  return NULL;
101}
102
103/* configuration information */
104
105#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
106#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
107
108#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
109#define CONFIGURE_POSIX_INIT_THREAD_TABLE
110
111#define CONFIGURE_INIT
112
113#include <rtems/confdefs.h>
114  /* end of file */
Note: See TracBrowser for help on using the repository browser.