source: rtems/testsuites/tmtests/tm14/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 14 ***" );
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  status = rtems_message_queue_create(
76    rtems_build_name( 'M', 'Q', '1', ' ' ),
77    OPERATION_COUNT,
78    MESSAGE_SIZE,
79    RTEMS_DEFAULT_ATTRIBUTES,
80    &Queue_id
81  );
82  directive_failed( status, "rtems_message_queue_create" );
83
84  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
85  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
86    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
87
88  for( index = 0; index < operation_count ; index++ ) {
89    status = rtems_task_create(
90      rtems_build_name( 'T', 'I', 'M', 'E' ),
91      priority,
92      RTEMS_MINIMUM_STACK_SIZE,
93      RTEMS_DEFAULT_MODES,
94      RTEMS_DEFAULT_ATTRIBUTES,
95      &task_id
96    );
97    directive_failed( status, "rtems_task_create LOOP" );
98
99    priority--;
100
101    if ( index==operation_count-1 ) task_entry = High_task;
102    else                            task_entry = Low_tasks;
103
104    status = rtems_task_start( task_id, task_entry, 0 );
105    directive_failed( status, "rtems_task_start LOOP" );
106  }
107}
108
109rtems_task High_task(
110  rtems_task_argument argument
111)
112{
113  int  index;
114
115  benchmark_timer_initialize();
116    for ( index=1 ; index < operation_count ; index++ )
117      (void) benchmark_timer_empty_function();
118  overhead = benchmark_timer_read();
119
120  benchmark_timer_initialize();
121    for ( index=1 ; index <= operation_count ; index++ )
122      (void) rtems_message_queue_urgent( Queue_id, Buffer, MESSAGE_SIZE );
123  end_time = benchmark_timer_read();
124
125  put_time(
126    "rtems_message_queue_urgent: task readied returns to caller",
127    end_time,
128    operation_count,
129    overhead,
130    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
131  );
132
133  puts( "*** END OF TEST 14 ***" );
134  rtems_test_exit( 0 );
135}
136
137rtems_task Low_tasks(
138  rtems_task_argument argument
139)
140{
141  size_t  size;
142
143  (void) rtems_message_queue_receive(
144           Queue_id,
145           (long (*)[4]) Buffer,
146           &size,
147           RTEMS_DEFAULT_OPTIONS,
148           RTEMS_NO_TIMEOUT
149         );
150}
Note: See TracBrowser for help on using the repository browser.