1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2013. |
---|
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 | #define CONFIGURE_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | rtems_id High_id; |
---|
18 | rtems_id Low_id; |
---|
19 | rtems_id Semaphore_id; |
---|
20 | |
---|
21 | rtems_task High_task( |
---|
22 | rtems_task_argument argument |
---|
23 | ); |
---|
24 | |
---|
25 | rtems_task Middle_tasks( |
---|
26 | rtems_task_argument argument |
---|
27 | ); |
---|
28 | |
---|
29 | rtems_task Low_task( |
---|
30 | rtems_task_argument argument |
---|
31 | ); |
---|
32 | |
---|
33 | int operation_count = OPERATION_COUNT; |
---|
34 | |
---|
35 | void test_init(void); |
---|
36 | |
---|
37 | rtems_task Init( |
---|
38 | rtems_task_argument argument |
---|
39 | ) |
---|
40 | { |
---|
41 | rtems_status_code status; |
---|
42 | |
---|
43 | Print_Warning(); |
---|
44 | |
---|
45 | puts( "\n\n*** TIME TEST 2 ***" ); |
---|
46 | |
---|
47 | test_init(); |
---|
48 | |
---|
49 | status = rtems_task_delete( RTEMS_SELF ); |
---|
50 | directive_failed( status, "rtems_task_delete" ); |
---|
51 | } |
---|
52 | |
---|
53 | void test_init(void) |
---|
54 | { |
---|
55 | rtems_status_code status; |
---|
56 | int index; |
---|
57 | rtems_task_priority priority; |
---|
58 | |
---|
59 | priority = 2; |
---|
60 | |
---|
61 | status = rtems_task_create( |
---|
62 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
63 | priority, |
---|
64 | RTEMS_MINIMUM_STACK_SIZE, |
---|
65 | RTEMS_DEFAULT_MODES, |
---|
66 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
67 | &High_id |
---|
68 | ); |
---|
69 | directive_failed( status, "rtems_task_create of high task" ); |
---|
70 | |
---|
71 | priority++; |
---|
72 | |
---|
73 | status = rtems_task_start( High_id, High_task, 0 ); |
---|
74 | directive_failed( status, "rtems_task_start of high task" ); |
---|
75 | |
---|
76 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u ) |
---|
77 | operation_count = (int) (RTEMS_MAXIMUM_PRIORITY - 2u); |
---|
78 | for ( index=2 ; index < operation_count ; index++ ) { |
---|
79 | status = rtems_task_create( |
---|
80 | rtems_build_name( 'M', 'I', 'D', ' ' ), |
---|
81 | priority, |
---|
82 | RTEMS_MINIMUM_STACK_SIZE, |
---|
83 | RTEMS_DEFAULT_MODES, |
---|
84 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
85 | &Low_id |
---|
86 | ); |
---|
87 | directive_failed( status, "rtems_task_create middle" ); |
---|
88 | |
---|
89 | priority++; |
---|
90 | |
---|
91 | status = rtems_task_start( Low_id, Middle_tasks, 0 ); |
---|
92 | directive_failed( status, "rtems_task_start middle" ); |
---|
93 | } |
---|
94 | |
---|
95 | status = rtems_task_create( |
---|
96 | rtems_build_name( 'L', 'O', 'W', ' ' ), |
---|
97 | priority, |
---|
98 | RTEMS_MINIMUM_STACK_SIZE, |
---|
99 | RTEMS_DEFAULT_MODES, |
---|
100 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
101 | &Low_id |
---|
102 | ); |
---|
103 | directive_failed( status, "rtems_task_create low" ); |
---|
104 | |
---|
105 | status = rtems_task_start( Low_id, Low_task, 0 ); |
---|
106 | directive_failed( status, "rtems_task_start low" ); |
---|
107 | |
---|
108 | status = rtems_semaphore_create( |
---|
109 | rtems_build_name( 'S', 'M', '1', ' '), |
---|
110 | 0, |
---|
111 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
112 | RTEMS_NO_PRIORITY, |
---|
113 | &Semaphore_id |
---|
114 | ); |
---|
115 | directive_failed( status, "rtems_semaphore_create of SM1" ); |
---|
116 | } |
---|
117 | |
---|
118 | rtems_task High_task( |
---|
119 | rtems_task_argument argument |
---|
120 | ) |
---|
121 | { |
---|
122 | /* start blocking rtems_semaphore_obtain time */ |
---|
123 | benchmark_timer_initialize(); |
---|
124 | |
---|
125 | (void) rtems_semaphore_obtain( |
---|
126 | Semaphore_id, |
---|
127 | RTEMS_DEFAULT_OPTIONS, |
---|
128 | RTEMS_NO_TIMEOUT |
---|
129 | ); |
---|
130 | } |
---|
131 | |
---|
132 | rtems_task Middle_tasks( |
---|
133 | rtems_task_argument argument |
---|
134 | ) |
---|
135 | { |
---|
136 | (void) rtems_semaphore_obtain( |
---|
137 | Semaphore_id, |
---|
138 | RTEMS_DEFAULT_OPTIONS, |
---|
139 | RTEMS_NO_TIMEOUT |
---|
140 | ); |
---|
141 | } |
---|
142 | |
---|
143 | rtems_task Low_task( |
---|
144 | rtems_task_argument argument |
---|
145 | ) |
---|
146 | { |
---|
147 | end_time = benchmark_timer_read(); |
---|
148 | |
---|
149 | put_time( |
---|
150 | "rtems_semaphore_obtain: not available caller blocks", |
---|
151 | end_time, |
---|
152 | operation_count - 1, |
---|
153 | 0, |
---|
154 | CALLING_OVERHEAD_SEMAPHORE_OBTAIN |
---|
155 | ); |
---|
156 | |
---|
157 | puts( "*** END OF TEST 2 ***" ); |
---|
158 | rtems_test_exit( 0 ); |
---|
159 | } |
---|