source: rtems/c/src/tests/sptests/sp32/init.c @ 0af7c20

4.104.114.84.95
Last change on this file since 0af7c20 was 0af7c20, checked in by Joel Sherrill <joel.sherrill@…>, on 09/14/02 at 18:47:07

2002-09-14 Aaron J. Grier <aaron@…>

  • PR271 was not applicable against the current source but included a nice test that Joel decided to add to the tree as sp32.
  • sp32/Makefile.am, sp32/init.c, sp32/sp32.scn: New file.
  • Makefile.am, configure.ac: Modified to reflect addition.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/* spmonotonic -- sanity check the rate monotonic manager
2 *
3 * license and distribution terms for this file may be found in the file
4 * LICENSE in this distribution or at
5 * http://www.OARcorp.com/rtems/license.html .
6 *
7 * $Id$
8 */
9
10#include <tmacros.h>  /* includes bsp.h, stdio, etc... */
11
12/* prototype */
13rtems_task Init (rtems_task_argument ignored);
14
15#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
16
17#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
18#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
19#define CONFIGURE_MAXIMUM_TASKS                         1
20#define CONFIGURE_MAXIMUM_PERIODS               1
21
22#define CONFIGURE_INIT
23
24#include <confdefs.h>
25
26rtems_task Init(
27    rtems_task_argument ignored
28) {
29  rtems_status_code     status;
30  rtems_interval                timestamps[6],
31                        wantintervals[5] =
32                            { 1, 50, 200, 25, 3 };
33  rtems_name            period_name =
34                            rtems_build_name('P','E','R','a');
35  rtems_id              period_id;
36  int                   loopy;
37
38  printf("\n\n*** TEST 32 ***\n");
39
40  /* create period */
41  status = rtems_rate_monotonic_create(
42      period_name,
43      &period_id
44  );
45  directive_failed(status, "rate_monotonic_create");
46
47  /* start period with initial value */
48  status = rtems_rate_monotonic_period(
49      period_id,
50      wantintervals[0]
51  );
52  directive_failed(status, "rate_monotonic_period");
53
54  /* get our first timestamp */
55  status = rtems_clock_get(
56      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
57      &timestamps[0]
58  );
59  directive_failed(status, "clock_get");
60
61  /* loop through and gather more timestamps */
62  for (loopy = 1; loopy < 5; loopy++) {
63
64        status = rtems_rate_monotonic_period(
65            period_id,
66            wantintervals[loopy]
67        );
68        directive_failed(status, "rate_monotonic_period");
69
70        status = rtems_clock_get(
71            RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
72            &timestamps[loopy]
73        );
74        directive_failed(status, "clock_get");
75  }
76
77  /* block one last time */
78  status = rtems_rate_monotonic_period(
79      period_id,
80      1
81  );
82  directive_failed(status, "rate_monotonic_period");
83
84  /* get one last timestamp */
85  status = rtems_clock_get(
86      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
87      &timestamps[loopy]
88  );
89  directive_failed(status, "clock_get");
90
91  /* cancel the period */
92  status = rtems_rate_monotonic_cancel(period_id);
93  directive_failed(status, "rate_monotonic_cancel");
94
95  /* delete it */
96  status = rtems_rate_monotonic_delete(period_id);
97  directive_failed(status, "rate_monotonic_delete");
98
99  /* tabulate and print results */
100  for (loopy = 0; loopy < 5; loopy++) {
101        printf(
102            "period %d: measured %d tick(s), wanted %d\n",
103            loopy, timestamps[loopy+1] - timestamps[loopy],
104            wantintervals[loopy]
105        );
106  }
107
108  /* the end */
109  printf("*** END OF TEST SP32 ***\n");
110  exit(0);
111}
Note: See TracBrowser for help on using the repository browser.