source: rtems/testsuites/tmtests/tm10/task1.c @ c499856

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.6 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
17rtems_id Queue_id;
18long Buffer[4];
19
20rtems_task High_task(
21  rtems_task_argument argument
22);
23
24rtems_task Middle_tasks(
25  rtems_task_argument argument
26);
27
28rtems_task Low_task(
29  rtems_task_argument argument
30);
31
32void test_init(void);
33
34int operation_count = OPERATION_COUNT;
35
36rtems_task Init(
37  rtems_task_argument argument
38)
39{
40  rtems_status_code status;
41
42  Print_Warning();
43
44  puts( "\n\n*** TIME TEST 10 ***" );
45
46  test_init();
47
48  status = rtems_task_delete( RTEMS_SELF );
49  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
50}
51
52void test_init()
53{
54  int                 index;
55  size_t              size;
56  rtems_task_entry    task_entry;
57  rtems_status_code   status;
58  rtems_task_priority priority;
59  rtems_id            task_id;
60
61  priority = 2;
62
63  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
64    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
65
66  for( index = 0; index < operation_count ; index++ ) {
67    status = rtems_task_create(
68      rtems_build_name( 'T', 'I', 'M', 'E' ),
69      priority,
70      RTEMS_MINIMUM_STACK_SIZE,
71      RTEMS_DEFAULT_MODES,
72      RTEMS_DEFAULT_ATTRIBUTES,
73      &task_id
74    );
75    directive_failed( status, "rtems_task_create LOOP" );
76
77    priority++;
78
79    if ( index==0 )                    task_entry = High_task;
80    else if ( index==operation_count-1 ) task_entry = Low_task;
81    else                               task_entry = Middle_tasks;
82
83    status = rtems_task_start( task_id, task_entry, 0 );
84    directive_failed( status, "rtems_task_start LOOP" );
85  }
86
87  status = rtems_message_queue_create(
88    1,
89    (uint32_t)operation_count,
90    16,
91    RTEMS_DEFAULT_ATTRIBUTES,
92    &Queue_id
93  );
94  directive_failed( status, "rtems_message_queue_create" );
95
96  benchmark_timer_initialize();
97    for ( index=1 ; index < operation_count ; index++ )
98      (void) benchmark_timer_empty_function();
99  overhead = benchmark_timer_read();
100
101  benchmark_timer_initialize();
102    for ( index=1 ; index < operation_count ; index++ )
103      (void) rtems_message_queue_receive(
104               Queue_id,
105               (long (*)[4]) Buffer,
106               &size,
107               RTEMS_NO_WAIT,
108               RTEMS_NO_TIMEOUT
109             );
110  end_time = benchmark_timer_read();
111
112  put_time(
113    "rtems_message_queue_receive: not available NO_WAIT",
114    end_time,
115    operation_count,
116    overhead,
117    CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE
118  );
119
120}
121
122rtems_task High_task(
123  rtems_task_argument argument
124)
125{
126  size_t  size;
127
128  benchmark_timer_initialize();
129     (void) rtems_message_queue_receive(
130              Queue_id,
131              (long (*)[4]) Buffer,
132              &size,
133              RTEMS_DEFAULT_OPTIONS,
134              RTEMS_NO_TIMEOUT
135            );
136}
137
138rtems_task Middle_tasks(
139  rtems_task_argument argument
140)
141{
142  size_t  size;
143
144  (void) rtems_message_queue_receive(
145           Queue_id,
146           (long (*)[4]) Buffer,
147           &size,
148           RTEMS_DEFAULT_OPTIONS,
149           RTEMS_NO_TIMEOUT
150         );
151}
152
153
154rtems_task Low_task(
155  rtems_task_argument argument
156)
157{
158  end_time = benchmark_timer_read();
159
160  put_time(
161    "rtems_message_queue_receive: not available caller blocks",
162    end_time,
163    operation_count - 1,
164    0,
165    CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE
166  );
167
168  puts( "*** END OF TEST 10 ***" );
169  rtems_test_exit( 0 );
170}
Note: See TracBrowser for help on using the repository browser.