source: rtems/testsuites/psxtmtests/psxtmnanosleep02/init.c @ bb3484c9

5
Last change on this file since bb3484c9 was c4b8b147, checked in by Sebastian Huber <sebastian.huber@…>, on 11/03/17 at 07:35:38

tests: Use simple console driver

Update #3170.
Update #3199.

  • 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.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <timesys.h>
15#include <rtems/btimer.h>
16#include "test_support.h"
17
18#include <pthread.h>
19
20const char rtems_test_name[] = "PSXTMNANOSLEEP 02";
21
22/* forward declarations to avoid warnings */
23void *POSIX_Init(void *argument);
24void *Middle(void *argument);
25void *Low(void *argument);
26
27void *Low(
28  void *argument
29)
30{
31  benchmark_timer_t end_time;
32
33  end_time = benchmark_timer_read();
34
35  put_time(
36    "nanosleep: blocking",
37    end_time,
38    OPERATION_COUNT,
39    0,
40    0
41  );
42
43  TEST_END();
44
45  rtems_test_exit( 0 );
46  return NULL;
47}
48
49void *Middle(
50  void *argument
51)
52{
53  /* calling nanosleep */
54  struct timespec sleepTime;
55  sleepTime.tv_sec = 0;
56  sleepTime.tv_nsec = 1;
57
58  nanosleep(&sleepTime, (struct  timespec *) NULL);
59
60  return NULL;
61}
62
63void *POSIX_Init(
64  void *argument
65)
66{
67  int        i;
68  int        status;
69  pthread_t  threadId;
70  struct timespec sleepTime;
71  struct timespec remainder;
72
73  sleepTime.tv_sec = 0;
74  sleepTime.tv_nsec = 1;
75  remainder.tv_sec = 0;
76  remainder.tv_nsec = 0;
77
78  TEST_BEGIN();
79
80  for ( i=0 ; i < OPERATION_COUNT - 1 ; i++ ) {
81    status = pthread_create( &threadId, NULL, Middle, NULL );
82    rtems_test_assert( !status );
83  }
84
85  status = pthread_create( &threadId, NULL, Low, NULL );
86  rtems_test_assert( !status );
87
88  /* start the timer and switch through all the other tasks */
89  benchmark_timer_initialize();
90  /* calling nanosleep*/
91  nanosleep(&sleepTime, &remainder);
92
93  return NULL;
94}
95
96/* configuration information */
97
98#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_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.