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 Queue_id; |
---|
18 | |
---|
19 | long Buffer[4]; |
---|
20 | |
---|
21 | rtems_task test_init( |
---|
22 | rtems_task_argument argument |
---|
23 | ); |
---|
24 | |
---|
25 | rtems_task Middle_tasks( |
---|
26 | rtems_task_argument argument |
---|
27 | ); |
---|
28 | |
---|
29 | rtems_task High_task( |
---|
30 | rtems_task_argument argument |
---|
31 | ); |
---|
32 | |
---|
33 | #define MESSAGE_SIZE (sizeof(long) * 4) |
---|
34 | |
---|
35 | int operation_count = OPERATION_COUNT; |
---|
36 | |
---|
37 | void Init( |
---|
38 | rtems_task_argument argument |
---|
39 | ) |
---|
40 | { |
---|
41 | rtems_status_code status; |
---|
42 | rtems_id id; |
---|
43 | |
---|
44 | Print_Warning(); |
---|
45 | |
---|
46 | puts( "\n\n*** TIME TEST 13 ***" ); |
---|
47 | |
---|
48 | status = rtems_task_create( |
---|
49 | 1, |
---|
50 | RTEMS_MAXIMUM_PRIORITY - 1u, |
---|
51 | RTEMS_MINIMUM_STACK_SIZE, |
---|
52 | RTEMS_DEFAULT_MODES, |
---|
53 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
54 | &id |
---|
55 | ); |
---|
56 | directive_failed( status, "rtems_task_create" ); |
---|
57 | |
---|
58 | status = rtems_task_start( id, test_init, 0 ); |
---|
59 | directive_failed( status, "rtems_task_start" ); |
---|
60 | |
---|
61 | status = rtems_task_delete( RTEMS_SELF ); |
---|
62 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
63 | } |
---|
64 | |
---|
65 | rtems_task test_init( |
---|
66 | rtems_task_argument argument |
---|
67 | ) |
---|
68 | { |
---|
69 | int index; |
---|
70 | rtems_task_entry task_entry; |
---|
71 | rtems_task_priority priority; |
---|
72 | rtems_id task_id; |
---|
73 | rtems_status_code status; |
---|
74 | |
---|
75 | /* As each task is started, it preempts this task and |
---|
76 | * performs a blocking rtems_message_queue_receive. Upon completion of |
---|
77 | * this loop all created tasks are blocked. |
---|
78 | */ |
---|
79 | |
---|
80 | status = rtems_message_queue_create( |
---|
81 | rtems_build_name( 'M', 'Q', '1', ' ' ), |
---|
82 | OPERATION_COUNT, |
---|
83 | MESSAGE_SIZE, |
---|
84 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
85 | &Queue_id |
---|
86 | ); |
---|
87 | directive_failed( status, "rtems_message_queue_create" ); |
---|
88 | |
---|
89 | priority = RTEMS_MAXIMUM_PRIORITY - 2u; |
---|
90 | |
---|
91 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u ) |
---|
92 | operation_count = (int)(RTEMS_MAXIMUM_PRIORITY - 2u); |
---|
93 | |
---|
94 | for( index = 0; index < operation_count ; index++ ) { |
---|
95 | status = rtems_task_create( |
---|
96 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
97 | priority, |
---|
98 | RTEMS_MINIMUM_STACK_SIZE, |
---|
99 | RTEMS_DEFAULT_MODES, |
---|
100 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
101 | &task_id |
---|
102 | ); |
---|
103 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
104 | |
---|
105 | priority--; |
---|
106 | |
---|
107 | if ( index==operation_count-1 ) task_entry = High_task; |
---|
108 | else task_entry = Middle_tasks; |
---|
109 | |
---|
110 | status = rtems_task_start( task_id, task_entry, 0 ); |
---|
111 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
112 | } |
---|
113 | |
---|
114 | benchmark_timer_initialize(); |
---|
115 | (void) rtems_message_queue_urgent( Queue_id, Buffer, MESSAGE_SIZE ); |
---|
116 | } |
---|
117 | |
---|
118 | rtems_task Middle_tasks( |
---|
119 | rtems_task_argument argument |
---|
120 | ) |
---|
121 | { |
---|
122 | size_t size; |
---|
123 | |
---|
124 | (void) rtems_message_queue_receive( |
---|
125 | Queue_id, |
---|
126 | (long (*)[4]) Buffer, |
---|
127 | &size, |
---|
128 | RTEMS_DEFAULT_OPTIONS, |
---|
129 | RTEMS_NO_TIMEOUT |
---|
130 | ); |
---|
131 | |
---|
132 | (void) rtems_message_queue_urgent( Queue_id, (long (*)[4]) Buffer, size ); |
---|
133 | } |
---|
134 | |
---|
135 | rtems_task High_task( |
---|
136 | rtems_task_argument argument |
---|
137 | ) |
---|
138 | { |
---|
139 | size_t size; |
---|
140 | |
---|
141 | (void) rtems_message_queue_receive( |
---|
142 | Queue_id, |
---|
143 | (long (*)[4]) Buffer, |
---|
144 | &size, |
---|
145 | RTEMS_DEFAULT_OPTIONS, |
---|
146 | RTEMS_NO_TIMEOUT |
---|
147 | ); |
---|
148 | |
---|
149 | end_time = benchmark_timer_read(); |
---|
150 | |
---|
151 | put_time( |
---|
152 | "rtems_message_queue_urgent: task readied preempts caller", |
---|
153 | end_time, |
---|
154 | operation_count, |
---|
155 | 0, |
---|
156 | CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT |
---|
157 | ); |
---|
158 | |
---|
159 | puts( "*** END OF TEST 13 ***" ); |
---|
160 | rtems_test_exit( 0 ); |
---|
161 | } |
---|