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

5
Last change on this file since e58e29fd was e58e29fd, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/17 at 06:58:55

Remove coverhd.h

This header file contained timing overhead values which are hard to
maintain.

Update #3254.

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