source: rtems/testsuites/tmtests/tm14/task1.c @ 2ead50a

4.115
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on 03/21/14 at 15:48:01

tmtests: convert to test.h

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[ac7d5ef0]1/*
[9410d011]2 *  COPYRIGHT (c) 1989-2013.
[ac7d5ef0]3 *  On-Line Applications Research Corporation (OAR).
4 *
[98e4ebf5]5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
[c499856]7 *  http://www.rtems.org/license/LICENSE.
[ac7d5ef0]8 */
9
[a4bc4d6e]10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
[d1128e2]14#define CONFIGURE_INIT
[ac7d5ef0]15#include "system.h"
16
[2ead50a]17const char rtems_test_name[] = "TIME TEST 14";
18
[ac7d5ef0]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
[df49c60]35#define MESSAGE_SIZE (sizeof(long) * 4)
[ac7d5ef0]36
[4389287a]37int operation_count = OPERATION_COUNT;
38
[ac7d5ef0]39rtems_task Init(
40  rtems_task_argument argument
41)
42{
43  rtems_id          task_id;
44  rtems_status_code status;
45
[3a4ae6c]46  Print_Warning();
47
[2ead50a]48  TEST_BEGIN();
[ac7d5ef0]49
50  status = rtems_task_create(
51    1,
[1055ce20]52    RTEMS_MAXIMUM_PRIORITY - 1u,
[3652ad35]53    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]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{
[1055ce20]71  int                  index;
[ac7d5ef0]72  rtems_task_entry     task_entry;
73  rtems_task_priority  priority;
74  rtems_id             task_id;
75  rtems_status_code    status;
76
77  status = rtems_message_queue_create(
78    rtems_build_name( 'M', 'Q', '1', ' ' ),
79    OPERATION_COUNT,
[df49c60]80    MESSAGE_SIZE,
[ac7d5ef0]81    RTEMS_DEFAULT_ATTRIBUTES,
82    &Queue_id
83  );
84  directive_failed( status, "rtems_message_queue_create" );
85
[1055ce20]86  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
87  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
88    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
[ac7d5ef0]89
[4389287a]90  for( index = 0; index < operation_count ; index++ ) {
[ac7d5ef0]91    status = rtems_task_create(
92      rtems_build_name( 'T', 'I', 'M', 'E' ),
93      priority,
[3652ad35]94      RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]95      RTEMS_DEFAULT_MODES,
96      RTEMS_DEFAULT_ATTRIBUTES,
97      &task_id
98    );
99    directive_failed( status, "rtems_task_create LOOP" );
100
101    priority--;
102
[4389287a]103    if ( index==operation_count-1 ) task_entry = High_task;
104    else                            task_entry = Low_tasks;
[ac7d5ef0]105
106    status = rtems_task_start( task_id, task_entry, 0 );
107    directive_failed( status, "rtems_task_start LOOP" );
108  }
109}
110
111rtems_task High_task(
112  rtems_task_argument argument
113)
114{
[1055ce20]115  int  index;
[ac7d5ef0]116
[dbf4f17]117  benchmark_timer_initialize();
[4389287a]118    for ( index=1 ; index < operation_count ; index++ )
[dbf4f17]119      (void) benchmark_timer_empty_function();
120  overhead = benchmark_timer_read();
[ac7d5ef0]121
[dbf4f17]122  benchmark_timer_initialize();
[4389287a]123    for ( index=1 ; index <= operation_count ; index++ )
[df49c60]124      (void) rtems_message_queue_urgent( Queue_id, Buffer, MESSAGE_SIZE );
[dbf4f17]125  end_time = benchmark_timer_read();
[ac7d5ef0]126
127  put_time(
[9410d011]128    "rtems_message_queue_urgent: task readied returns to caller",
[ac7d5ef0]129    end_time,
[4389287a]130    operation_count,
[ac7d5ef0]131    overhead,
132    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
133  );
134
[2ead50a]135  TEST_END();
[b454bc9]136  rtems_test_exit( 0 );
[ac7d5ef0]137}
138
139rtems_task Low_tasks(
140  rtems_task_argument argument
141)
142{
[5343588]143  size_t  size;
[4b374f36]144
[ac7d5ef0]145  (void) rtems_message_queue_receive(
146           Queue_id,
147           (long (*)[4]) Buffer,
[4b374f36]148           &size,
[ac7d5ef0]149           RTEMS_DEFAULT_OPTIONS,
150           RTEMS_NO_TIMEOUT
151         );
152}
Note: See TracBrowser for help on using the repository browser.