OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [tmtests/] [tm09/] [task1.c] - Blame information for rev 484

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *
3
 *  COPYRIGHT (c) 1989-1999.
4
 *  On-Line Applications Research Corporation (OAR).
5
 *
6
 *  The license and distribution terms for this file may be
7
 *  found in the file LICENSE in this distribution or at
8
 *  http://www.OARcorp.com/rtems/license.html.
9
 *
10
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:42 chris Exp $
11
 */
12
 
13
#define TEST_INIT
14
#include "system.h"
15
 
16
rtems_id Queue_id;
17
 
18
rtems_task Test_task(
19
  rtems_task_argument argument
20
);
21
void queue_test();
22
 
23
rtems_task Init(
24
  rtems_task_argument argument
25
)
26
{
27
  rtems_status_code status;
28
 
29
  Print_Warning();
30
 
31
  puts( "\n\n*** TIME TEST 9 ***" );
32
 
33
  status = rtems_task_create(
34
    1,
35
    128,
36
    RTEMS_MINIMUM_STACK_SIZE * 2,
37
    RTEMS_DEFAULT_MODES,
38
    RTEMS_DEFAULT_ATTRIBUTES,
39
    &Task_id[ 1 ]
40
  );
41
  directive_failed( status, "rtems_task_create" );
42
 
43
  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
44
  directive_failed( status, "rtems_task_start" );
45
 
46
  status = rtems_task_delete( RTEMS_SELF );
47
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
48
}
49
 
50
#define MESSAGE_SIZE (sizeof(long) * 4)
51
 
52
rtems_task Test_task (
53
  rtems_task_argument argument
54
)
55
{
56
  Timer_initialize();
57
    rtems_message_queue_create(
58
      1,
59
      OPERATION_COUNT,
60
      MESSAGE_SIZE,
61
      RTEMS_DEFAULT_ATTRIBUTES,
62
      &Queue_id
63
    );
64
  end_time = Read_timer();
65
 
66
  put_time(
67
    "rtems_message_queue_create",
68
    end_time,
69
    1,
70
    0,
71
    CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE
72
  );
73
 
74
  queue_test();
75
 
76
  Timer_initialize();
77
    rtems_message_queue_delete( Queue_id );
78
  end_time = Read_timer();
79
 
80
  put_time(
81
    "rtems_message_queue_delete",
82
    end_time,
83
    1,
84
    0,
85
    CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE
86
  );
87
 
88
  puts( "*** END OF TEST 9 ***" );
89
  exit( 0 );
90
}
91
 
92
void queue_test()
93
{
94
  rtems_unsigned32  send_loop_time;
95
  rtems_unsigned32  urgent_loop_time;
96
  rtems_unsigned32  receive_loop_time;
97
  rtems_unsigned32  send_time;
98
  rtems_unsigned32  urgent_time;
99
  rtems_unsigned32  receive_time;
100
  rtems_unsigned32  empty_flush_time;
101
  rtems_unsigned32  flush_time;
102
  rtems_unsigned32  empty_flush_count;
103
  rtems_unsigned32  flush_count;
104
  rtems_unsigned32  index;
105
  rtems_unsigned32  iterations;
106
  long              buffer[4];
107
  rtems_status_code status;
108
  rtems_unsigned32  size;
109
 
110
  send_loop_time    = 0;
111
  urgent_loop_time  = 0;
112
  receive_loop_time = 0;
113
  send_time         = 0;
114
  urgent_time       = 0;
115
  receive_time      = 0;
116
  empty_flush_time  = 0;
117
  flush_time        = 0;
118
  flush_count       = 0;
119
  empty_flush_count = 0;
120
 
121
  for ( iterations = 1 ; iterations <= OPERATION_COUNT ; iterations++ ) {
122
 
123
    Timer_initialize();
124
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
125
        (void) Empty_function();
126
    send_loop_time += Read_timer();
127
 
128
    Timer_initialize();
129
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
130
        (void) Empty_function();
131
    urgent_loop_time += Read_timer();
132
 
133
    Timer_initialize();
134
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
135
        (void) Empty_function();
136
    receive_loop_time += Read_timer();
137
 
138
    Timer_initialize();
139
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
140
        (void) rtems_message_queue_send( Queue_id, buffer, MESSAGE_SIZE );
141
    send_time += Read_timer();
142
 
143
    Timer_initialize();
144
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
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
    receive_time += Read_timer();
153
 
154
    Timer_initialize();
155
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
156
        (void) rtems_message_queue_urgent( Queue_id, buffer, MESSAGE_SIZE );
157
    urgent_time += Read_timer();
158
 
159
    Timer_initialize();
160
      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
161
        (void) rtems_message_queue_receive(
162
                 Queue_id,
163
                 (long (*)[4])buffer,
164
                 &size,
165
                 RTEMS_DEFAULT_OPTIONS,
166
                 RTEMS_NO_TIMEOUT
167
               );
168
    receive_time += Read_timer();
169
 
170
    Timer_initialize();
171
      rtems_message_queue_flush( Queue_id, &empty_flush_count );
172
    empty_flush_time += Read_timer();
173
 
174
    /* send one message to flush */
175
    status = rtems_message_queue_send(
176
       Queue_id,
177
       (long (*)[4])buffer,
178
       MESSAGE_SIZE
179
    );
180
    directive_failed( status, "rtems_message_queue_send" );
181
 
182
    Timer_initialize();
183
      rtems_message_queue_flush( Queue_id, &flush_count );
184
    flush_time += Read_timer();
185
  }
186
 
187
  put_time(
188
    "rtems_message_queue_send: no waiting tasks",
189
    send_time,
190
    OPERATION_COUNT * OPERATION_COUNT,
191
    send_loop_time,
192
    CALLING_OVERHEAD_MESSAGE_QUEUE_SEND
193
  );
194
 
195
  put_time(
196
    "rtems_message_queue_urgent: no waiting tasks",
197
    urgent_time,
198
    OPERATION_COUNT * OPERATION_COUNT,
199
    urgent_loop_time,
200
    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
201
  );
202
 
203
  put_time(
204
    "rtems_message_queue_receive: available",
205
    receive_time,
206
    OPERATION_COUNT * OPERATION_COUNT * 2,
207
    receive_loop_time * 2,
208
    CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE
209
  );
210
 
211
  put_time(
212
    "rtems_message_queue_flush: no messages flushed",
213
    empty_flush_time,
214
    OPERATION_COUNT,
215
    0,
216
    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
217
  );
218
 
219
  put_time(
220
    "rtems_message_queue_flush: messages flushed",
221
    flush_time,
222
    OPERATION_COUNT,
223
    0,
224
    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
225
  );
226
 
227
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.