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 Flusher_id; |
---|
18 | rtems_id Semaphore; |
---|
19 | volatile bool case_hit; |
---|
20 | |
---|
21 | Thread_blocking_operation_States getState(void) |
---|
22 | { |
---|
23 | Objects_Locations location; |
---|
24 | Semaphore_Control *sem; |
---|
25 | |
---|
26 | sem = (Semaphore_Control *)_Objects_Get( |
---|
27 | &_Semaphore_Information, Semaphore, &location ); |
---|
28 | if ( location != OBJECTS_LOCAL ) { |
---|
29 | puts( "Bad object lookup" ); |
---|
30 | rtems_test_exit(0); |
---|
31 | } |
---|
32 | _Thread_Unnest_dispatch(); |
---|
33 | |
---|
34 | return sem->Core_control.semaphore.Wait_queue.sync_state; |
---|
35 | } |
---|
36 | |
---|
37 | rtems_timer_service_routine test_release_from_isr( |
---|
38 | rtems_id timer, |
---|
39 | void *arg |
---|
40 | ) |
---|
41 | { |
---|
42 | if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) { |
---|
43 | case_hit = true; |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | rtems_task Flusher( |
---|
48 | rtems_task_argument ignored |
---|
49 | ) |
---|
50 | { |
---|
51 | rtems_status_code sc; |
---|
52 | |
---|
53 | while (1) { |
---|
54 | sc = rtems_semaphore_flush( Semaphore ); |
---|
55 | directive_failed( sc, "rtems_semaphore_flush" ); |
---|
56 | |
---|
57 | sc = rtems_task_wake_after( 2 ); |
---|
58 | directive_failed( sc, "rtems_task_wake_after" ); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | rtems_task Init( |
---|
63 | rtems_task_argument ignored |
---|
64 | ) |
---|
65 | { |
---|
66 | rtems_status_code sc; |
---|
67 | |
---|
68 | puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION 09 ***" ); |
---|
69 | |
---|
70 | puts( "Init - Test may not be able to detect case is hit reliably" ); |
---|
71 | puts( "Init - Trying to generate timeout from ISR while blocking" ); |
---|
72 | sc = rtems_semaphore_create( |
---|
73 | rtems_build_name( 'S', 'M', '1', ' ' ), |
---|
74 | 1, |
---|
75 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
76 | RTEMS_NO_PRIORITY, |
---|
77 | &Semaphore |
---|
78 | ); |
---|
79 | directive_failed( sc, "rtems_semaphore_create of SM1" ); |
---|
80 | |
---|
81 | Main_task = rtems_task_self(); |
---|
82 | |
---|
83 | sc = rtems_task_create( |
---|
84 | rtems_build_name( 'F', 'L', 'S', 'H' ), |
---|
85 | 1, |
---|
86 | RTEMS_MINIMUM_STACK_SIZE, |
---|
87 | RTEMS_DEFAULT_MODES, |
---|
88 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
89 | &Flusher_id |
---|
90 | ); |
---|
91 | directive_failed( sc, "rtems_task_create" ); |
---|
92 | |
---|
93 | sc = rtems_task_start( Flusher_id, Flusher, 0 ); |
---|
94 | directive_failed( sc, "rtems_task_start" ); |
---|
95 | |
---|
96 | interrupt_critical_section_test_support_initialize( test_release_from_isr ); |
---|
97 | |
---|
98 | case_hit = false; |
---|
99 | |
---|
100 | while (!case_hit) { |
---|
101 | interrupt_critical_section_test_support_delay(); |
---|
102 | |
---|
103 | (void) rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); |
---|
104 | } |
---|
105 | |
---|
106 | puts( "Init - Case hit" ); |
---|
107 | |
---|
108 | puts( "*** END OF TEST INTERRUPT CRITICAL SECTION 09 ***" ); |
---|
109 | rtems_test_exit(0); |
---|
110 | } |
---|
111 | |
---|
112 | /* configuration information */ |
---|
113 | |
---|
114 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
115 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
116 | |
---|
117 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
118 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
119 | #define CONFIGURE_MAXIMUM_SEMAPHORES 1 |
---|
120 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
121 | #define CONFIGURE_MICROSECONDS_PER_TICK 1000 |
---|
122 | |
---|
123 | #define CONFIGURE_INIT |
---|
124 | #include <rtems/confdefs.h> |
---|
125 | |
---|
126 | /* global variables */ |
---|