source: rtems/testsuites/tmtests/tm11/task1.c @ af43554

5
Last change on this file since af43554 was af43554, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:11

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

Update #3170.
Update #3199.

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