source: rtems/testsuites/psxtmtests/psxtmnanosleep02/init.c @ 50162e0

4.115
Last change on this file since 50162e0 was 50162e0, checked in by Joel Sherrill <joel.sherrill@…>, on 12/07/13 at 18:18:02

psxtmtests: Make output more uniform

  • Property mode set to 100644
File size: 2.0 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.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <timesys.h>
15#include <rtems/timerdrv.h>
16#include "test_support.h"
17
18#include <pthread.h>
19
20/* forward declarations to avoid warnings */
21void *POSIX_Init(void *argument);
22void *Middle(void *argument);
23void *Low(void *argument);
24
25void *Low(
26  void *argument
27)
28{
29  benchmark_timer_t end_time;
30
31  end_time = benchmark_timer_read();
32
33  put_time(
34    "nanosleep: blocking",
35    end_time,
36    OPERATION_COUNT,
37    0,
38    0
39  );
40
41  puts( "*** END OF POSIX TIME TEST PSXTMNANOSLEEP02 ***" );
42
43  rtems_test_exit( 0 );
44  return NULL;
45}
46
47void *Middle(
48  void *argument
49)
50{
51  /* calling nanosleep */
52  struct timespec sleepTime;
53  sleepTime.tv_sec = 0;
54  sleepTime.tv_nsec = 1;
55
56  nanosleep(&sleepTime, (struct  timespec *) NULL);
57
58  return NULL;
59}
60
61void *POSIX_Init(
62  void *argument
63)
64{
65  int        i;
66  int        status;
67  pthread_t  threadId;
68  struct timespec sleepTime;
69  struct timespec remainder;
70
71  sleepTime.tv_sec = 0;
72  sleepTime.tv_nsec = 1;
73  remainder.tv_sec = 0;
74  remainder.tv_nsec = 0;
75
76  puts( "\n\n*** POSIX TIME TEST PSXTMNANOSLEEP02 ***" );
77
78  for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
79    status = pthread_create( &threadId, NULL, Middle, NULL );
80    rtems_test_assert( !status );
81  }
82 
83  status = pthread_create( &threadId, NULL, Low, NULL );
84  rtems_test_assert( !status );
85
86  /* start the timer and switch through all the other tasks */
87  benchmark_timer_initialize();
88  /* calling nanosleep*/
89  nanosleep(&sleepTime, &remainder);
90
91  return NULL;
92}
93
94/* configuration information */
95
96#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
97#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
98
99#define CONFIGURE_MAXIMUM_POSIX_THREADS     OPERATION_COUNT + 2
100#define CONFIGURE_POSIX_INIT_THREAD_TABLE
101
102#define CONFIGURE_INIT
103
104#include <rtems/confdefs.h>
105  /* end of file */
Note: See TracBrowser for help on using the repository browser.