source: rtems/testsuites/psxtmtests/psxtmthread03/init.c @ 4a2d1ea

4.115
Last change on this file since 4a2d1ea was 4a2d1ea, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/08/11 at 08:26:13

2011-02-08 Ralf Corsépius <ralf.corsepius@…>

  • psxtmmutex02/init.c, psxtmthread03/init.c: end_time is a uint32_t.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2010.
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 *  $Id$
10 */
11
12#include <coverhd.h>
13#include <tmacros.h>
14#include <timesys.h>
15#include "test_support.h"
16#include <pthread.h>
17#include <sched.h>
18#include <rtems/timerdrv.h>
19
20void *Low(
21  void *argument
22)
23{
24  uint32_t end_time;
25
26  /*
27   * Now we have finished the thread startup overhead,
28   * so let other threads run.  When we return, we can
29   * finish the benchmark.
30   */
31  sched_yield();
32    /* let other threads run */
33
34  end_time = benchmark_timer_read();
35
36  put_time(
37    "pthread_exit",
38    end_time,
39    OPERATION_COUNT,
40    0,
41    0
42  );
43
44  puts( "*** END OF POSIX TIME TEST TM02 ***" );
45  rtems_test_exit( 0 );
46  return NULL;
47}
48
49void *Middle(
50  void *argument
51)
52{
53  /*
54   * Now we have finished the thread startup overhead,
55   * so let other threads run.  When we return, we can
56   * finish the benchmark.
57   */
58  sched_yield();
59    /* let other threads run */
60
61  pthread_exit( NULL );
62  return NULL;
63}
64
65void *POSIX_Init(
66  void *argument
67)
68{
69  int        i;
70  int        status;
71  pthread_t  threadId;
72
73  puts( "\n\n*** POSIX TIME TEST TM02 ***" );
74
75  for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
76    status = pthread_create( &threadId, NULL, Middle, NULL );
77    rtems_test_assert( !status );
78  }
79 
80  status = pthread_create( &threadId, NULL, Low, NULL );
81  rtems_test_assert( !status );
82
83  /*
84   * Let the other threads start so the thread startup overhead,
85   * is accounted for.  When we return, we can start the benchmark.
86   */
87  sched_yield();
88    /* let other threads run */
89
90  /* start the timer and switch through all the other tasks */
91  benchmark_timer_initialize();
92  pthread_exit( NULL );
93  return NULL;
94}
95
96/* configuration information */
97
98#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
99#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
100
101#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
102#define CONFIGURE_POSIX_INIT_THREAD_TABLE
103
104#define CONFIGURE_INIT
105
106#include <rtems/confdefs.h>
107  /* end of file */
Note: See TracBrowser for help on using the repository browser.