source: rtems/c/src/tests/sptests/sp32/init.c @ 6d1bb1f7

Last change on this file since 6d1bb1f7 was 6d1bb1f7, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:46:38

2003-09-04 Joel Sherrill <joel@…>

  • sp01/init.c, sp01/sp01.doc, sp01/system.h, sp01/task1.c, sp02/init.c, sp02/preempt.c, sp02/sp02.doc, sp02/system.h, sp02/task1.c, sp02/task2.c, sp02/task3.c, sp03/init.c, sp03/sp03.doc, sp03/system.h, sp03/task1.c, sp03/task2.c, sp04/init.c, sp04/sp04.doc, sp04/system.h, sp04/task1.c, sp04/task2.c, sp04/task3.c, sp04/tswitch.c, sp05/init.c, sp05/sp05.doc, sp05/system.h, sp05/task1.c, sp05/task2.c, sp05/task3.c, sp06/init.c, sp06/sp06.doc, sp06/system.h, sp06/task1.c, sp06/task2.c, sp06/task3.c, sp07/init.c, sp07/sp07.doc, sp07/system.h, sp07/task1.c, sp07/task2.c, sp07/task3.c, sp07/task4.c, sp07/taskexit.c, sp07/tcreate.c, sp07/tdelete.c, sp07/trestart.c, sp07/tstart.c, sp08/init.c, sp08/sp08.doc, sp08/system.h, sp08/task1.c, sp09/delay.c, sp09/init.c, sp09/isr.c, sp09/screen01.c, sp09/screen02.c, sp09/screen03.c, sp09/screen04.c, sp09/screen05.c, sp09/screen06.c, sp09/screen07.c, sp09/screen08.c, sp09/screen09.c, sp09/screen10.c, sp09/screen11.c, sp09/screen12.c, sp09/screen13.c, sp09/screen14.c, sp09/sp09.doc, sp09/system.h, sp09/task1.c, sp09/task2.c, sp09/task3.c, sp09/task4.c, sp11/init.c, sp11/sp11.doc, sp11/system.h, sp11/task1.c, sp11/task2.c, sp11/timer.c, sp12/init.c, sp12/pridrv.c, sp12/pritask.c, sp12/sp12.doc, sp12/system.h, sp12/task1.c, sp12/task2.c, sp12/task3.c, sp12/task4.c, sp12/task5.c, sp13/fillbuff.c, sp13/init.c, sp13/putbuff.c, sp13/sp13.doc, sp13/system.h, sp13/task1.c, sp13/task2.c, sp13/task3.c, sp14/asr.c, sp14/init.c, sp14/sp14.doc, sp14/system.h, sp14/task1.c, sp14/task2.c, sp15/init.c, sp15/sp15.doc, sp15/system.h, sp15/task1.c, sp16/init.c, sp16/sp16.doc, sp16/system.h, sp16/task1.c, sp16/task2.c, sp16/task3.c, sp16/task4.c, sp16/task5.c, sp17/asr.c, sp17/init.c, sp17/sp17.doc, sp17/system.h, sp17/task1.c, sp17/task2.c, sp19/first.c, sp19/fptask.c, sp19/fptest.h, sp19/init.c, sp19/inttest.h, sp19/sp19.doc, sp19/system.h, sp19/task1.c, sp20/getall.c, sp20/init.c, sp20/sp20.doc, sp20/system.h, sp20/task1.c, sp21/init.c, sp21/sp21.doc, sp21/system.h, sp21/task1.c, sp22/delay.c, sp22/init.c, sp22/prtime.c, sp22/sp22.doc, sp22/system.h, sp22/task1.c, sp23/init.c, sp23/sp23.doc, sp23/system.h, sp23/task1.c, sp24/init.c, sp24/resume.c, sp24/sp24.doc, sp24/system.h, sp24/task1.c, sp25/init.c, sp25/sp25.doc, sp25/system.h, sp25/task1.c, sp26/init.c, sp26/sp26.doc, sp26/system.h, sp26/task1.c, sp30/init.c, sp30/resume.c, sp30/sp30.doc, sp30/system.h, sp30/task1.c, sp31/delay.c, sp31/init.c, sp31/prtime.c, sp31/sp31.doc, sp31/system.h, sp31/task1.c, sp32/init.c, spfatal/fatal.c, spfatal/init.c, spfatal/puterr.c, spfatal/spfatal.doc, spfatal/system.h, spfatal/task1.c, spsize/getint.c, spsize/init.c, spsize/size.c, spsize/system.h: URL for license changed.
  • 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.rtems.com/license/LICENSE .
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.