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

4.104.114.9
Last change on this file since ac9d3cf8 was ac9d3cf8, checked in by Joel Sherrill <joel.sherrill@…>, on May 7, 2008 at 9:57:43 PM

2008-05-07 Joel Sherrill <joel.sherrill@…>

  • sp32/init.c: Formatting.
  • 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 CONFIGURE_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] = { 1, 50, 200, 25, 3 };
33  rtems_name         period_name = rtems_build_name('P','E','R','a');
34  rtems_id           period_id;
35  int                loopy;
36
37  printf("\n\n*** TEST 32 ***\n");
38
39  /* create period */
40  status = rtems_rate_monotonic_create(
41      period_name,
42      &period_id
43  );
44  directive_failed(status, "rate_monotonic_create");
45
46  /* start period with initial value */
47  status = rtems_rate_monotonic_period(
48      period_id,
49      wantintervals[0]
50  );
51  directive_failed(status, "rate_monotonic_period");
52
53  /* get our first timestamp */
54  status = rtems_clock_get(
55      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
56      &timestamps[0]
57  );
58  directive_failed(status, "clock_get");
59
60  /* loop through and gather more timestamps */
61  for (loopy = 1; loopy < 5; loopy++) {
62
63    status = rtems_rate_monotonic_period(
64        period_id,
65        wantintervals[loopy]
66    );
67    directive_failed(status, "rate_monotonic_period");
68
69    status = rtems_clock_get(
70        RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
71        &timestamps[loopy]
72    );
73    directive_failed(status, "clock_get");
74  }
75
76  /* block one last time */
77  status = rtems_rate_monotonic_period(
78      period_id,
79      1
80  );
81  directive_failed(status, "rate_monotonic_period");
82
83  /* get one last timestamp */
84  status = rtems_clock_get(
85      RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
86      &timestamps[loopy]
87  );
88  directive_failed(status, "clock_get");
89
90  /* cancel the period */
91  status = rtems_rate_monotonic_cancel(period_id);
92  directive_failed(status, "rate_monotonic_cancel");
93
94  /* delete it */
95  status = rtems_rate_monotonic_delete(period_id);
96  directive_failed(status, "rate_monotonic_delete");
97
98  /* tabulate and print results */
99  for (loopy = 0; loopy < 5; loopy++) {
100    printf(
101        "period %d: measured %d tick(s), wanted %d\n",
102        loopy, timestamps[loopy+1] - timestamps[loopy],
103        wantintervals[loopy]
104    );
105  }
106
107  /* the end */
108  puts("*** END OF TEST 32 ***");
109  rtems_test_exit(0);
110}
Note: See TracBrowser for help on using the repository browser.