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 | #include <tmacros.h> |
---|
13 | #include <intrcritical.h> |
---|
14 | |
---|
15 | #define TEST_NAME "15" |
---|
16 | #define INIT_PRIORITY 2 |
---|
17 | #define BLOCKER_PRIORITY 1 |
---|
18 | |
---|
19 | rtems_id Main_task; |
---|
20 | rtems_id Secondary_task_id; |
---|
21 | rtems_id Semaphore; |
---|
22 | |
---|
23 | rtems_timer_service_routine test_release_from_isr( |
---|
24 | rtems_id timer, |
---|
25 | void *arg |
---|
26 | ) |
---|
27 | { |
---|
28 | } |
---|
29 | |
---|
30 | rtems_task Secondary_task( |
---|
31 | rtems_task_argument ignored |
---|
32 | ) |
---|
33 | { |
---|
34 | rtems_status_code sc; |
---|
35 | |
---|
36 | while (1) { |
---|
37 | |
---|
38 | sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); |
---|
39 | fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" ); |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | rtems_task Init( |
---|
44 | rtems_task_argument ignored |
---|
45 | ) |
---|
46 | { |
---|
47 | rtems_status_code sc; |
---|
48 | int resets; |
---|
49 | |
---|
50 | puts( |
---|
51 | "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***\n" |
---|
52 | "Init - Trying to generate timeout of a thread while another is blocking\n" |
---|
53 | "Init - on the same thread queue\n" |
---|
54 | "Init - There is no way for the test to know if it hits the case" |
---|
55 | ); |
---|
56 | |
---|
57 | puts( "Init - rtems_semaphore_create - OK" ); |
---|
58 | sc = rtems_semaphore_create( |
---|
59 | rtems_build_name( 'S', 'M', '1', ' ' ), |
---|
60 | 0, |
---|
61 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
62 | RTEMS_NO_PRIORITY, |
---|
63 | &Semaphore |
---|
64 | ); |
---|
65 | directive_failed( sc, "rtems_semaphore_create of SM1" ); |
---|
66 | |
---|
67 | puts( "Init - rtems_task_create - OK" ); |
---|
68 | sc = rtems_task_create( |
---|
69 | rtems_build_name( 'B', 'L', 'C', 'K' ), |
---|
70 | BLOCKER_PRIORITY, |
---|
71 | RTEMS_MINIMUM_STACK_SIZE, |
---|
72 | RTEMS_NO_PREEMPT, |
---|
73 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
74 | &Secondary_task_id |
---|
75 | ); |
---|
76 | directive_failed( sc, "rtems_task_create" ); |
---|
77 | |
---|
78 | sc = rtems_task_start( Secondary_task_id, Secondary_task, 0 ); |
---|
79 | directive_failed( sc, "rtems_task_start" ); |
---|
80 | |
---|
81 | Main_task = rtems_task_self(); |
---|
82 | |
---|
83 | interrupt_critical_section_test_support_initialize( NULL ); |
---|
84 | |
---|
85 | for (resets=0 ; resets<10 ;) { |
---|
86 | if ( interrupt_critical_section_test_support_delay() ) |
---|
87 | resets++; |
---|
88 | |
---|
89 | sc = rtems_task_restart( Secondary_task_id, 1 ); |
---|
90 | directive_failed( sc, "rtems_task_restart" ); |
---|
91 | |
---|
92 | sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); |
---|
93 | fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" ); |
---|
94 | } |
---|
95 | |
---|
96 | puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" ); |
---|
97 | rtems_test_exit(0); |
---|
98 | } |
---|
99 | |
---|
100 | /* configuration information */ |
---|
101 | |
---|
102 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
103 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
104 | |
---|
105 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
106 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
107 | #define CONFIGURE_MICROSECONDS_PER_TICK 1000 |
---|
108 | #define CONFIGURE_INIT_TASK_PRIORITY INIT_PRIORITY |
---|
109 | #define CONFIGURE_INIT_TASK_MODE RTEMS_PREEMPT |
---|
110 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
111 | |
---|
112 | #define CONFIGURE_INIT |
---|
113 | #include <rtems/confdefs.h> |
---|
114 | |
---|
115 | /* global variables */ |
---|