source: rtems/testsuites/psxtmtests/psxtmthread03/init.c @ fd46711

4.11
Last change on this file since fd46711 was fd46711, checked in by bjorn larsson <bjornlarsson@…>, on Mar 21, 2014 at 8:35:26 PM

psxtmtests: Add test.h support

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