1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2009. |
---|
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 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 |
---|
13 | #include <tmacros.h> |
---|
14 | #include <intrcritical.h> |
---|
15 | |
---|
16 | rtems_id Main_task; |
---|
17 | rtems_id Period; |
---|
18 | volatile bool case_hit; |
---|
19 | |
---|
20 | rtems_rate_monotonic_period_states getState(void) |
---|
21 | { |
---|
22 | Objects_Locations location; |
---|
23 | Rate_monotonic_Control *period; |
---|
24 | |
---|
25 | period = (Rate_monotonic_Control *)_Objects_Get( |
---|
26 | &_Rate_monotonic_Information, Period, &location ); |
---|
27 | if ( location != OBJECTS_LOCAL ) { |
---|
28 | puts( "Bad object lookup" ); |
---|
29 | rtems_test_exit(0); |
---|
30 | } |
---|
31 | _Thread_Unnest_dispatch(); |
---|
32 | |
---|
33 | return period->state; |
---|
34 | } |
---|
35 | |
---|
36 | rtems_timer_service_routine test_release_from_isr( |
---|
37 | rtems_id timer, |
---|
38 | void *arg |
---|
39 | ) |
---|
40 | { |
---|
41 | if ( getState() == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING ) |
---|
42 | case_hit = true; |
---|
43 | } |
---|
44 | |
---|
45 | rtems_task Init( |
---|
46 | rtems_task_argument ignored |
---|
47 | ) |
---|
48 | { |
---|
49 | rtems_status_code sc; |
---|
50 | int resets; |
---|
51 | |
---|
52 | puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION 08 ***" ); |
---|
53 | |
---|
54 | puts( "Init - Trying to generate period ending while blocking" ); |
---|
55 | |
---|
56 | puts( "Init - rtems_rate_monotonic_create - OK" ); |
---|
57 | sc = rtems_rate_monotonic_create( |
---|
58 | rtems_build_name( 'P', 'E', 'R', '1' ), |
---|
59 | &Period |
---|
60 | ); |
---|
61 | directive_failed( sc, "rtems_rate_monotonic_create" ); |
---|
62 | |
---|
63 | Main_task = rtems_task_self(); |
---|
64 | |
---|
65 | interrupt_critical_section_test_support_initialize( test_release_from_isr ); |
---|
66 | |
---|
67 | case_hit = false; |
---|
68 | |
---|
69 | for (resets=0 ; case_hit == false && resets< 2 ;) { |
---|
70 | if ( interrupt_critical_section_test_support_delay() ) |
---|
71 | resets++; |
---|
72 | |
---|
73 | sc = rtems_rate_monotonic_period( Period, 1 ); |
---|
74 | if ( sc == RTEMS_TIMEOUT ) |
---|
75 | continue; |
---|
76 | directive_failed( sc, "rtems_monotonic_period"); |
---|
77 | } |
---|
78 | |
---|
79 | if ( case_hit ) { |
---|
80 | puts( "Init - It appears the case has been hit" ); |
---|
81 | puts( "*** END OF TEST INTERRUPT CRITICAL SECTION 08 ***" ); |
---|
82 | } else |
---|
83 | puts( "Init - Case not hit - ran too long" ); |
---|
84 | rtems_test_exit(0); |
---|
85 | } |
---|
86 | |
---|
87 | /* configuration information */ |
---|
88 | |
---|
89 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
90 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
91 | |
---|
92 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
93 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
94 | #define CONFIGURE_MAXIMUM_PERIODS 1 |
---|
95 | #define CONFIGURE_MICROSECONDS_PER_TICK 1000 |
---|
96 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
97 | |
---|
98 | #define CONFIGURE_INIT |
---|
99 | #include <rtems/confdefs.h> |
---|
100 | |
---|
101 | /* global variables */ |
---|