source: rtems/testsuites/tmtests/tm12/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.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
17rtems_id Queue_id;
18
19long Buffer[4];
20
21rtems_task test_init(
22  rtems_task_argument argument
23);
24
25rtems_task High_task(
26  rtems_task_argument argument
27);
28
29rtems_task Low_tasks(
30  rtems_task_argument argument
31);
32
33#define MESSAGE_SIZE (sizeof(long) * 4)
34
35int operation_count = OPERATION_COUNT;
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  rtems_id          task_id;
42  rtems_status_code status;
43
44  Print_Warning();
45
46  puts( "\n\n*** TIME TEST 12 ***" );
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    &task_id
55  );
56  directive_failed( status, "rtems_task_create" );
57
58  status = rtems_task_start( task_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
65rtems_task test_init(
66  rtems_task_argument argument
67)
68{
69  int                  index;
70  rtems_task_entry     task_entry;
71  rtems_task_priority  priority;
72  rtems_id             task_id;
73  rtems_status_code    status;
74
75
76  status = rtems_message_queue_create(
77    rtems_build_name( 'M', 'Q', '1', ' ' ),
78    (uint32_t) operation_count,
79    MESSAGE_SIZE,
80    RTEMS_DEFAULT_ATTRIBUTES,
81    &Queue_id
82  );
83  directive_failed( status, "rtems_message_queue_create" );
84
85  priority = RTEMS_MAXIMUM_PRIORITY - 1u;
86
87  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
88    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
89
90  for( index = 0; index < operation_count ; index++ ) {
91    status = rtems_task_create(
92      rtems_build_name( 'T', 'I', 'M', 'E' ),
93      priority,
94      RTEMS_MINIMUM_STACK_SIZE,
95      RTEMS_DEFAULT_MODES,
96      RTEMS_DEFAULT_ATTRIBUTES,
97      &task_id
98    );
99    directive_failed( status, "rtems_task_create LOOP" );
100
101    priority--;
102
103    if ( index == operation_count-1 ) task_entry = High_task;
104    else                              task_entry = Low_tasks;
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{
115  int  index;
116
117  benchmark_timer_initialize();
118    for ( index=1 ; index < operation_count ; index++ )
119      (void) benchmark_timer_empty_function();
120  overhead = benchmark_timer_read();
121
122  benchmark_timer_initialize();
123    for ( index=1 ; index < operation_count ; index++ )
124      (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE );
125  end_time = benchmark_timer_read();
126
127  put_time(
128    "rtems_message_queue_send: task readied returns to caller",
129    end_time,
130    operation_count - 1,
131    overhead,
132    CALLING_OVERHEAD_MESSAGE_QUEUE_SEND
133  );
134
135  puts( "*** END OF TEST 12 ***" );
136  rtems_test_exit( 0 );
137}
138
139rtems_task Low_tasks(
140  rtems_task_argument argument
141)
142{
143  size_t  size;
144
145  (void) rtems_message_queue_receive(
146           Queue_id,
147           (long (*)[4]) Buffer,
148           &size,
149           RTEMS_DEFAULT_OPTIONS,
150           RTEMS_NO_TIMEOUT
151         );
152}
Note: See TracBrowser for help on using the repository browser.