source: rtems/testsuites/psxtmtests/psxtmnanosleep02/init.c @ 1c2ab39

4.115
Last change on this file since 1c2ab39 was 1c2ab39, checked in by Joel Sherrill <joel.sherrill@…>, on 07/21/11 at 13:46:49

2011-07-21 Joel Sherrill <joel.sherrill@…>

  • psxtmmutex02/init.c, psxtmmutex05/init.c, psxtmmutex06/init.c, psxtmnanosleep02/init.c, psxtmsleep02/init.c, psxtmthread01/init.c, psxtmthread03/init.c: Standardize start and end test messages.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
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#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <timesys.h>
17#include <rtems/timerdrv.h>
18#include "test_support.h"
19
20#include <pthread.h>
21
22void *Low(
23  void *argument
24)
25{
26  long end_time;
27
28  end_time = benchmark_timer_read();
29
30  put_time(
31    "nanosleep - blocking",
32    end_time,
33    OPERATION_COUNT,
34    0,
35    0
36  );
37
38  puts( "*** END OF POSIX TIME TEST PSXTMNANOSLEEP02 ***" );
39
40  rtems_test_exit( 0 );
41  return NULL;
42}
43
44void *Middle(
45  void *argument
46)
47{
48  /* calling nanosleep */
49  struct timespec sleepTime;
50  sleepTime.tv_sec = 0;
51  sleepTime.tv_nsec = 1;
52
53  nanosleep(&sleepTime, (struct  timespec *) NULL);
54
55  return NULL;
56}
57
58void *POSIX_Init(
59  void *argument
60)
61{
62  int        i;
63  int        status;
64  pthread_t  threadId;
65  struct timespec sleepTime;
66  struct timespec remainder;
67
68  sleepTime.tv_sec = 0;
69  sleepTime.tv_nsec = 1;
70  remainder.tv_sec = 0;
71  remainder.tv_nsec = 0;
72
73  puts( "\n\n*** POSIX TIME TEST PSXTMNANOSLEEP02 ***" );
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  /* start the timer and switch through all the other tasks */
84  benchmark_timer_initialize();
85  /* calling nanosleep*/
86  nanosleep(&sleepTime, &remainder);
87
88  return NULL;
89}
90
91/* configuration information */
92
93#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
94#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
95
96#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
97#define CONFIGURE_POSIX_INIT_THREAD_TABLE
98
99#define CONFIGURE_INIT
100
101#include <rtems/confdefs.h>
102  /* end of file */
Note: See TracBrowser for help on using the repository browser.