source: rtems/testsuites/psxtests/psx11/task.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*  Task_1
2 *
3 *  This routine serves as a test task.  It verifies the basic task
4 *  switching capabilities of the executive.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-2009.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include "system.h"
24#include <time.h>
25#include <sched.h>
26
27void diff_timespec(
28  struct timespec *start,
29  struct timespec *stop,
30  struct timespec *result
31)
32{
33   const long nsecs_per_sec = 1000000000;
34
35   result->tv_sec = stop->tv_sec - start->tv_sec;
36   if ( stop->tv_nsec < start->tv_nsec ) {
37      result->tv_nsec = nsecs_per_sec - start->tv_nsec + stop->tv_nsec;
38      result->tv_sec--;
39   } else
40      result->tv_nsec = stop->tv_nsec - start->tv_nsec;
41
42}
43
44void *Task_1(
45  void *argument
46)
47{
48  int status;
49  struct timespec start;
50  struct timespec current;
51  struct timespec difference;
52  struct timespec delay;
53
54  status = clock_gettime( CLOCK_REALTIME, &start );
55  rtems_test_assert( !status );
56
57  status = sched_rr_get_interval( getpid(), &delay );
58  rtems_test_assert( !status );
59
60  /* double the rr interval for confidence */
61
62  delay.tv_sec *= 2;
63  delay.tv_nsec *= 2;
64  if ( delay.tv_nsec >= 1000000000 ) {   /* handle overflow/carry */
65    delay.tv_nsec -= 1000000000;
66    delay.tv_sec++;
67  }
68
69
70  puts( "Task_1: killing time" );
71  for ( ; ; ) {
72
73    status = clock_gettime( CLOCK_REALTIME, &current );
74    rtems_test_assert( !status );
75
76    diff_timespec( &start, &current, &difference );
77
78    if ( difference.tv_sec < delay.tv_sec )
79      continue;
80
81    if ( difference.tv_sec > delay.tv_sec )
82      break;
83
84    if ( difference.tv_nsec > delay.tv_nsec )
85      break;
86
87  }
88
89  puts( "Task_1: exitting" );
90  pthread_exit( NULL );
91
92  return NULL; /* just so the compiler thinks we returned something */
93}
Note: See TracBrowser for help on using the repository browser.