source: rtems/testsuites/tmtests/tm12/task1.c @ 96e4b22

5
Last change on this file since 96e4b22 was 96e4b22, checked in by Chris Johns <chrisj@…>, on 03/06/19 at 09:39:29

testsuite: Make the OPERATION_COUNT a test configuration parameter.

  • Add a small memory test config file.
  • Update the small memory PowerPC BSPs to use the new test config.
  • 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#if !defined(OPERATION_COUNT)
11#define OPERATION_COUNT 100
12#endif
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#define CONFIGURE_INIT
19#include "system.h"
20
21const char rtems_test_name[] = "TIME TEST 12";
22
23rtems_id Queue_id;
24
25long Buffer[4];
26
27rtems_task test_init(
28  rtems_task_argument argument
29);
30
31rtems_task High_task(
32  rtems_task_argument argument
33);
34
35rtems_task Low_tasks(
36  rtems_task_argument argument
37);
38
39#define MESSAGE_SIZE (sizeof(long) * 4)
40
41int operation_count = OPERATION_COUNT;
42
43rtems_task Init(
44  rtems_task_argument argument
45)
46{
47  rtems_id          task_id;
48  rtems_status_code status;
49
50  Print_Warning();
51
52  TEST_BEGIN();
53
54  status = rtems_task_create(
55    1,
56    RTEMS_MAXIMUM_PRIORITY - 1u,
57    RTEMS_MINIMUM_STACK_SIZE,
58    RTEMS_DEFAULT_MODES,
59    RTEMS_DEFAULT_ATTRIBUTES,
60    &task_id
61  );
62  directive_failed( status, "rtems_task_create" );
63
64  status = rtems_task_start( task_id, test_init, 0 );
65  directive_failed( status, "rtems_task_start" );
66
67  rtems_task_exit();
68}
69
70rtems_task test_init(
71  rtems_task_argument argument
72)
73{
74  int                  index;
75  rtems_task_entry     task_entry;
76  rtems_task_priority  priority;
77  rtems_id             task_id;
78  rtems_status_code    status;
79
80
81  status = rtems_message_queue_create(
82    rtems_build_name( 'M', 'Q', '1', ' ' ),
83    (uint32_t) operation_count,
84    MESSAGE_SIZE,
85    RTEMS_DEFAULT_ATTRIBUTES,
86    &Queue_id
87  );
88  directive_failed( status, "rtems_message_queue_create" );
89
90  priority = RTEMS_MAXIMUM_PRIORITY - 1u;
91
92  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
93    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
94
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 = Low_tasks;
110
111    status = rtems_task_start( task_id, task_entry, 0 );
112    directive_failed( status, "rtems_task_start LOOP" );
113  }
114}
115
116rtems_task High_task(
117  rtems_task_argument argument
118)
119{
120  int  index;
121
122  benchmark_timer_initialize();
123    for ( index=1 ; index < operation_count ; index++ )
124      (void) benchmark_timer_empty_function();
125  overhead = benchmark_timer_read();
126
127  benchmark_timer_initialize();
128    for ( index=1 ; index < operation_count ; index++ )
129      (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE );
130  end_time = benchmark_timer_read();
131
132  put_time(
133    "rtems_message_queue_send: task readied returns to caller",
134    end_time,
135    operation_count - 1,
136    overhead,
137    0
138  );
139
140  TEST_END();
141  rtems_test_exit( 0 );
142}
143
144rtems_task Low_tasks(
145  rtems_task_argument argument
146)
147{
148  size_t  size;
149
150  (void) rtems_message_queue_receive(
151           Queue_id,
152           (long (*)[4]) Buffer,
153           &size,
154           RTEMS_DEFAULT_OPTIONS,
155           RTEMS_NO_TIMEOUT
156         );
157}
Note: See TracBrowser for help on using the repository browser.