source: rtems/testsuites/tmtests/tm12/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.3 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 12";
18
19rtems_id Queue_id;
20
21long Buffer[4];
22
23rtems_task test_init(
24  rtems_task_argument argument
25);
26
27rtems_task High_task(
28  rtems_task_argument argument
29);
30
31rtems_task Low_tasks(
32  rtems_task_argument argument
33);
34
35#define MESSAGE_SIZE (sizeof(long) * 4)
36
37int operation_count = OPERATION_COUNT;
38
39rtems_task Init(
40  rtems_task_argument argument
41)
42{
43  rtems_id          task_id;
44  rtems_status_code status;
45
46  Print_Warning();
47
48  TEST_BEGIN();
49
50  status = rtems_task_create(
51    1,
52    RTEMS_MAXIMUM_PRIORITY - 1u,
53    RTEMS_MINIMUM_STACK_SIZE,
54    RTEMS_DEFAULT_MODES,
55    RTEMS_DEFAULT_ATTRIBUTES,
56    &task_id
57  );
58  directive_failed( status, "rtems_task_create" );
59
60  status = rtems_task_start( task_id, test_init, 0 );
61  directive_failed( status, "rtems_task_start" );
62
63  status = rtems_task_delete( RTEMS_SELF );
64  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
65}
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
78  status = rtems_message_queue_create(
79    rtems_build_name( 'M', 'Q', '1', ' ' ),
80    (uint32_t) operation_count,
81    MESSAGE_SIZE,
82    RTEMS_DEFAULT_ATTRIBUTES,
83    &Queue_id
84  );
85  directive_failed( status, "rtems_message_queue_create" );
86
87  priority = RTEMS_MAXIMUM_PRIORITY - 1u;
88
89  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
90    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
91
92  for( index = 0; index < operation_count ; index++ ) {
93    status = rtems_task_create(
94      rtems_build_name( 'T', 'I', 'M', 'E' ),
95      priority,
96      RTEMS_MINIMUM_STACK_SIZE,
97      RTEMS_DEFAULT_MODES,
98      RTEMS_DEFAULT_ATTRIBUTES,
99      &task_id
100    );
101    directive_failed( status, "rtems_task_create LOOP" );
102
103    priority--;
104
105    if ( index == operation_count-1 ) task_entry = High_task;
106    else                              task_entry = Low_tasks;
107
108    status = rtems_task_start( task_id, task_entry, 0 );
109    directive_failed( status, "rtems_task_start LOOP" );
110  }
111}
112
113rtems_task High_task(
114  rtems_task_argument argument
115)
116{
117  int  index;
118
119  benchmark_timer_initialize();
120    for ( index=1 ; index < operation_count ; index++ )
121      (void) benchmark_timer_empty_function();
122  overhead = benchmark_timer_read();
123
124  benchmark_timer_initialize();
125    for ( index=1 ; index < operation_count ; index++ )
126      (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE );
127  end_time = benchmark_timer_read();
128
129  put_time(
130    "rtems_message_queue_send: task readied returns to caller",
131    end_time,
132    operation_count - 1,
133    overhead,
134    CALLING_OVERHEAD_MESSAGE_QUEUE_SEND
135  );
136
137  TEST_END();
138  rtems_test_exit( 0 );
139}
140
141rtems_task Low_tasks(
142  rtems_task_argument argument
143)
144{
145  size_t  size;
146
147  (void) rtems_message_queue_receive(
148           Queue_id,
149           (long (*)[4]) Buffer,
150           &size,
151           RTEMS_DEFAULT_OPTIONS,
152           RTEMS_NO_TIMEOUT
153         );
154}
Note: See TracBrowser for help on using the repository browser.