1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2012. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <tmacros.h> /* includes bsp.h, stdio, etc... */ |
---|
15 | |
---|
16 | /* forward declarations to avoid warnings */ |
---|
17 | rtems_task Init(rtems_task_argument argument); |
---|
18 | |
---|
19 | rtems_task Init( |
---|
20 | rtems_task_argument ignored |
---|
21 | ) { |
---|
22 | rtems_status_code status; |
---|
23 | rtems_interval timestamps[6], |
---|
24 | wantintervals[5] = { 1, 50, 200, 25, 3 }; |
---|
25 | rtems_name period_name = rtems_build_name('P','E','R','a'); |
---|
26 | rtems_id period_id; |
---|
27 | int loopy; |
---|
28 | |
---|
29 | printf("\n\n*** TEST 32 ***\n"); |
---|
30 | |
---|
31 | /* create period */ |
---|
32 | status = rtems_rate_monotonic_create( |
---|
33 | period_name, |
---|
34 | &period_id |
---|
35 | ); |
---|
36 | directive_failed(status, "rate_monotonic_create"); |
---|
37 | |
---|
38 | /* start period with initial value */ |
---|
39 | status = rtems_rate_monotonic_period( period_id, wantintervals[0] ); |
---|
40 | directive_failed(status, "rate_monotonic_period #1"); |
---|
41 | |
---|
42 | /* get our first timestamp */ |
---|
43 | timestamps[0] = rtems_clock_get_ticks_since_boot(); |
---|
44 | |
---|
45 | /* loop through and gather more timestamps */ |
---|
46 | for (loopy = 1; loopy < 5; loopy++) { |
---|
47 | |
---|
48 | status = rtems_rate_monotonic_period( period_id, wantintervals[loopy] ); |
---|
49 | directive_failed(status, "rate_monotonic_period #2"); |
---|
50 | |
---|
51 | timestamps[loopy] = rtems_clock_get_ticks_since_boot(); |
---|
52 | } |
---|
53 | |
---|
54 | /* block one last time */ |
---|
55 | status = rtems_rate_monotonic_period( period_id, 1 ); |
---|
56 | directive_failed(status, "rate_monotonic_period #3"); |
---|
57 | |
---|
58 | /* get one last timestamp */ |
---|
59 | timestamps[loopy] = rtems_clock_get_ticks_since_boot(); |
---|
60 | |
---|
61 | /* cancel the period */ |
---|
62 | status = rtems_rate_monotonic_cancel(period_id); |
---|
63 | directive_failed(status, "rate_monotonic_cancel"); |
---|
64 | |
---|
65 | /* delete it */ |
---|
66 | status = rtems_rate_monotonic_delete(period_id); |
---|
67 | directive_failed(status, "rate_monotonic_delete"); |
---|
68 | |
---|
69 | /* tabulate and print results */ |
---|
70 | for (loopy = 0; loopy < 5; loopy++) { |
---|
71 | printf( |
---|
72 | "period %d: measured %" PRIdrtems_interval " tick(s), wanted %" |
---|
73 | PRIdrtems_interval "\n", |
---|
74 | loopy, |
---|
75 | timestamps[loopy+1] - timestamps[loopy], |
---|
76 | wantintervals[loopy] |
---|
77 | ); |
---|
78 | } |
---|
79 | |
---|
80 | puts("*** END OF TEST 32 ***"); |
---|
81 | rtems_test_exit(0); |
---|
82 | } |
---|
83 | |
---|
84 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
85 | |
---|
86 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
87 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
88 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
89 | #define CONFIGURE_MAXIMUM_PERIODS 1 |
---|
90 | |
---|
91 | #define CONFIGURE_MICROSECONDS_PER_TICK 100000 |
---|
92 | |
---|
93 | #define CONFIGURE_INIT |
---|
94 | |
---|
95 | #include <rtems/confdefs.h> |
---|
96 | |
---|