source: rtems/testsuites/sptests/sp32/init.c @ e8064503

4.104.114.84.95
Last change on this file since e8064503 was e8064503, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/01/04 at 15:16:30
  • sp01/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp02/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp03/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp04/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp05/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp06/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp07/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp08/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp09/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp11/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp12/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp13/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp14/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp15/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp16/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp17/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp19/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp20/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp21/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp22/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp23/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp24/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp25/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp26/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp27/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp28/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp29/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp30/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp31/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • sp32/init.c: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • spfatal/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • spsize/system.h: Include <rtems/confdefs.h> instead of <confdefs.h>.
  • Property mode set to 100644
File size: 2.7 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.rtems.com/license/LICENSE .
6 *
7 * $Id$
8 */
9
10#define TEST_INIT
11#include <tmacros.h>  /* includes bsp.h, stdio, etc... */
12
13/* prototype */
14rtems_task Init (rtems_task_argument ignored);
15
16#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
17
18#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
19#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
20#define CONFIGURE_MAXIMUM_TASKS                         1
21#define CONFIGURE_MAXIMUM_PERIODS               1
22
23#define CONFIGURE_INIT
24
25#include <rtems/confdefs.h>
26
27rtems_task Init(
28    rtems_task_argument ignored
29) {
30  rtems_status_code     status;
31  rtems_interval                timestamps[6],
32                        wantintervals[5] =
33                            { 1, 50, 200, 25, 3 };
34  rtems_name            period_name =
35                            rtems_build_name('P','E','R','a');
36  rtems_id              period_id;
37  int                   loopy;
38
39  printf("\n\n*** TEST 32 ***\n");
40
41  /* create period */
42  status = rtems_rate_monotonic_create(
43      period_name,
44      &period_id
45  );
46  directive_failed(status, "rate_monotonic_create");
47
48  /* start period with initial value */
49  status = rtems_rate_monotonic_period(
50      period_id,
51      wantintervals[0]
52  );
53  directive_failed(status, "rate_monotonic_period");
54
55  /* get our first timestamp */
56  status = rtems_clock_get(
57      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
58      &timestamps[0]
59  );
60  directive_failed(status, "clock_get");
61
62  /* loop through and gather more timestamps */
63  for (loopy = 1; loopy < 5; loopy++) {
64
65        status = rtems_rate_monotonic_period(
66            period_id,
67            wantintervals[loopy]
68        );
69        directive_failed(status, "rate_monotonic_period");
70
71        status = rtems_clock_get(
72            RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
73            &timestamps[loopy]
74        );
75        directive_failed(status, "clock_get");
76  }
77
78  /* block one last time */
79  status = rtems_rate_monotonic_period(
80      period_id,
81      1
82  );
83  directive_failed(status, "rate_monotonic_period");
84
85  /* get one last timestamp */
86  status = rtems_clock_get(
87      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
88      &timestamps[loopy]
89  );
90  directive_failed(status, "clock_get");
91
92  /* cancel the period */
93  status = rtems_rate_monotonic_cancel(period_id);
94  directive_failed(status, "rate_monotonic_cancel");
95
96  /* delete it */
97  status = rtems_rate_monotonic_delete(period_id);
98  directive_failed(status, "rate_monotonic_delete");
99
100  /* tabulate and print results */
101  for (loopy = 0; loopy < 5; loopy++) {
102        printf(
103            "period %d: measured %d tick(s), wanted %d\n",
104            loopy, timestamps[loopy+1] - timestamps[loopy],
105            wantintervals[loopy]
106        );
107  }
108
109  /* the end */
110  printf("*** END OF TEST SP32 ***\n");
111  exit(0);
112}
Note: See TracBrowser for help on using the repository browser.