OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [libtests/] [rtems++/] [Task1.cc] - Blame information for rev 214

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

Line No. Rev Author Line
1 30 unneback
/*  Task1
2
 *
3
 *  This task is the main line for the test. It creates other
4
 *  tasks which can create
5
 *
6
 *  Input parameters:
7
 *    argument - task argument
8
 *
9
 *  Output parameters:  NONE
10
 *
11
 *  COPYRIGHT (c) 1997
12
 *  Objective Design Systems Ltd Pty (ODS)
13
 *  All rights reserved (R) Objective Design Systems Ltd Pty
14
 *
15
 *  COPYRIGHT (c) 1989-1999.
16
 *  On-Line Applications Research Corporation (OAR).
17
 *
18
 *  The license and distribution terms for this file may be
19
 *  found in the file LICENSE in this distribution or at
20
 *  http://www.OARcorp.com/rtems/license.html.
21
 *
22
 *  $Id: Task1.cc,v 1.2 2001-09-27 12:02:13 chris Exp $
23
 */
24
 
25
#include <stdlib.h>
26
#include <string.h>
27
#include "System.h"
28
 
29
void Task1::body(rtems_task_argument argument)
30
{
31
  rtems_test_pause_and_screen_number(1);
32
 
33
  printf(" * START Task Class test *\n");
34
 
35
  printf("%s - test argument - ", name_string());
36
  if (argument != 0xDEADDEAD)
37
    printf("argument is not 0xDEADDEAD\n");
38
  else
39
    printf("argument matched\n");
40
 
41
  screen1();
42
  rtems_test_pause_and_screen_number(2);
43
 
44
  screen2();
45
  rtems_test_pause_and_screen_number(3);
46
 
47
  screen3();
48
  rtems_test_pause_and_screen_number(4);
49
 
50
  screen4();
51
  rtems_test_pause_and_screen_number(5);
52
 
53
  screen5();
54
  rtems_test_pause_and_screen_number(6);
55
 
56
  screen6();
57
 
58
  // do not call exit(0) from this thread as this object is static
59
  // the static destructor call delete the task which is calling exit
60
  // so exit never completes
61
 
62
  EndTask end_task("ENDT", (rtems_task_priority) 1, RTEMS_MINIMUM_STACK_SIZE * 6);
63
  end_task.start(0);
64
 
65
  rtemsEvent block_me;
66
  rtems_event_set out;
67
 
68
  block_me.receive(RTEMS_SIGNAL_0, out);
69
 
70
  printf("**** TASK 1 did not block ????\n");
71
}
72
 
73
void Task1::screen1(void)
74
{
75
  // create two local task objects to connect to this task
76
  rtemsTask local_task_1 = *this;
77
  rtemsTask local_task_2;
78
 
79
  local_task_2 = *this;
80
 
81
  // check the copy constructor works
82
  printf("%s - copy constructor - ", name_string());
83
  if (local_task_1.id_is() == id_is())
84
    printf("local and this id's match\n");
85
  else
86
    printf("local and this id's do not match\n");
87
 
88
  printf("%s - copy constructor - ", name_string());
89
  if (local_task_1.name_is() == name_is())
90
    printf("local and this name's match\n");
91
  else
92
    printf("local and this name's do not match\n");
93
 
94
  // check the copy operator works
95
  printf("%s - copy operator - ", name_string());
96
  if (local_task_2.id_is() == id_is())
97
    printf("local and this id's match\n");
98
  else
99
    printf("local and this id's do not match\n");
100
  printf("%s - copy operator - ", name_string());
101
  if (local_task_2.name_is() == name_is())
102
    printf("local and this name's match\n");
103
  else
104
    printf("local and this name's do not match\n");
105
 
106
  // check that the owner of the id cannot delete this task
107
  printf("%s - not owner destroy's task - ", local_task_1.name_string());
108
  local_task_1.destroy();
109
  printf("%s\n", local_task_1.last_status_string());
110
 
111
  // connect to a valid task
112
  printf("%s - connect to a local valid task name - ", local_task_2.name_string());
113
  local_task_2.connect("TA1 ", RTEMS_SEARCH_ALL_NODES);
114
  printf("%s\n", local_task_2.last_status_string());
115
 
116
  // connect to an invalid task
117
  printf("%s - connect to an invalid task name - ", local_task_2.name_string());
118
  local_task_2.connect("BADT", RTEMS_SEARCH_ALL_NODES);
119
  printf("%s\n", local_task_2.last_status_string());
120
 
121
  // connect to a task an invalid node
122
  printf("%s - connect to a task on an invalid node - ", local_task_2.name_string());
123
  local_task_2.connect("BADT", 10);
124
  printf("%s\n", local_task_2.last_status_string());
125
 
126
  // restart this task
127
  printf("%s - restart from a non-owner - ", name_string());
128
  local_task_1.restart(0);
129
  printf("%s\n", local_task_1.last_status_string());
130
}
131
 
132
void Task1::screen2(void)
133
{
134
  // wake after using this object
135
 
136
  printf("%s - wake after 0 secs - ", name_string());
137
  wake_after(0);
138
  printf("%s\n", last_status_string());
139
 
140
  printf("%s - wake after 500 msecs - ", name_string());
141
  wake_after(500000);
142
  printf("%s\n", last_status_string());
143
 
144
  printf("%s - wake after 5 secs - ", name_string());
145
  wake_after(5000000);
146
  printf("%s\n", last_status_string());
147
 
148
  printf("%s - wake when - to do\n", name_string());
149
 
150
  rtemsTask task_1 = *this;
151
 
152
  // wake after using a connected object
153
 
154
  printf("%s - connected object wake after 0 secs - ", task_1.name_string());
155
  task_1.wake_after(0);
156
  printf("%s\n", task_1.last_status_string());
157
 
158
  printf("%s - connected object wake after 500 msecs - ", task_1.name_string());
159
  task_1.wake_after(500000);
160
  printf("%s\n", task_1.last_status_string());
161
 
162
  printf("%s - connected object wake after 5 secs - ", task_1.name_string());
163
  task_1.wake_after(5000000);
164
  printf("%s\n", task_1.last_status_string());
165
 
166
  printf("%s - connected object wake when - to do\n", task_1.name_string());
167
 
168
  rtemsTask task_2;
169
 
170
  // wake after using a self object
171
 
172
  printf("%s - self object wake after 0 secs - ", task_2.name_string());
173
  task_2.wake_after(0);
174
  printf("%s\n", task_2.last_status_string());
175
 
176
  printf("%s - self object wake after 500 msecs - ", task_2.name_string());
177
  task_2.wake_after(500000);
178
  printf("%s\n", task_2.last_status_string());
179
 
180
  printf("%s - self object wake after 5 secs - ", task_2.name_string());
181
  task_2.wake_after(5000000);
182
  printf("%s\n", task_2.last_status_string());
183
 
184
  printf("%s - self object wake when - to do\n", task_2.name_string());
185
 
186
  rtems_task_priority current_priority;
187
  rtems_task_priority priority;
188
 
189
  // priorities with this object
190
 
191
  printf("%s - get priority - ", name_string());
192
  get_priority(current_priority);
193
  printf("%s, priority is %i\n", last_status_string(), current_priority);
194
 
195
  printf("%s - set priority to 512 - ", name_string());
196
  set_priority(512);
197
  printf("%s\n", last_status_string());
198
 
199
  printf("%s - set priority to 25 - ", name_string());
200
  set_priority(25);
201
  printf("%s\n", last_status_string());
202
 
203
  printf("%s - set priority to original - ", name_string());
204
  set_priority(current_priority, priority);
205
  printf("%s, priority was %i\n", last_status_string(), priority);
206
 
207
  // priorities with connected object
208
 
209
  printf("%s - connected object get priority - ", task_1.name_string());
210
  task_1.get_priority(current_priority);
211
  printf("%s, priority is %i\n", task_1.last_status_string(), current_priority);
212
 
213
  printf("%s - connected object set priority to 512 - ", task_1.name_string());
214
  task_1.set_priority(512);
215
  printf("%s\n", task_1.last_status_string());
216
 
217
  printf("%s - connected object set priority to 25 - ", task_1.name_string());
218
  task_1.set_priority(25);
219
  printf("%s\n", task_1.last_status_string());
220
 
221
  printf("%s - connected object set priority to original - ", task_1.name_string());
222
  task_1.set_priority(current_priority, priority);
223
  printf("%s, priority was %i\n", task_1.last_status_string(), priority);
224
 
225
  // priorities with self object
226
 
227
  printf("%s - self object get priority - ", task_2.name_string());
228
  task_2.get_priority(current_priority);
229
  printf("%s, priority is %i\n", task_2.last_status_string(), current_priority);
230
 
231
  printf("%s - self object set priority to 512 - ", task_2.name_string());
232
  task_2.set_priority(512);
233
  printf("%s\n", task_2.last_status_string());
234
 
235
  printf("%s - self object set priority to 25 - ", task_2.name_string());
236
  task_2.set_priority(25);
237
  printf("%s\n", task_2.last_status_string());
238
 
239
  printf("%s - self object set priority to original - ", task_2.name_string());
240
  task_2.set_priority(current_priority, priority);
241
  printf("%s, priority was %i\n", task_2.last_status_string(), priority);
242
 
243
  rtems_unsigned32 current_note;
244
  rtems_unsigned32 note;
245
 
246
  // notepad registers for this object
247
 
248
  printf("%s - get note - ", name_string());
249
  get_note(0, current_note);
250
  printf("%s, note is %i\n", last_status_string(), current_note);
251
 
252
  printf("%s - get with bad notepad number - ", name_string());
253
  get_note(100, current_note);
254
  printf("%s, note is %i\n", last_status_string(), current_note);
255
 
256
  printf("%s - set note to 0xDEADBEEF - ", name_string());
257
  set_note(0, 0xDEADBEEF);
258
  printf("%s\n", last_status_string());
259
 
260
  printf("%s - get note - ", name_string());
261
  get_note(0, note);
262
  printf("%s, note is 0x%08X\n", last_status_string(), note);
263
 
264
  printf("%s - set note to original value - ", name_string());
265
  set_note(0, current_note);
266
  printf("%s\n", last_status_string());
267
 
268
  // notepad registers for connected object
269
 
270
  printf("%s - connected object get note - ", task_1.name_string());
271
  task_1.get_note(0, current_note);
272
  printf("%s, notepad is %i\n", task_1.last_status_string(), current_note);
273
 
274
  printf("%s - connected object get with bad notepad number - ", task_1.name_string());
275
  task_1.get_note(100, current_note);
276
  printf("%s, note is %i\n", task_1.last_status_string(), current_note);
277
 
278
  printf("%s - connected object set note to 0xDEADBEEF - ", task_1.name_string());
279
  task_1.set_note(0, 0xDEADBEEF);
280
  printf("%s\n", task_1.last_status_string());
281
 
282
  printf("%s - connected object get note - ", task_1.name_string());
283
  task_1.get_note(0, note);
284
  printf("%s, note is 0x%08X\n", task_1.last_status_string(), note);
285
 
286
  printf("%s - connected object set note to original value - ", task_1.name_string());
287
  task_1.set_note(0, current_note);
288
  printf("%s\n", task_1.last_status_string());
289
 
290
  // notepad registers for self object
291
 
292
  printf("%s - self object get note - ", task_2.name_string());
293
  task_2.get_note(0, current_note);
294
  printf("%s, note is %i\n", task_2.last_status_string(), current_note);
295
 
296
  printf("%s - self object get with bad notepad number - ", task_2.name_string());
297
  task_2.get_note(100, current_note);
298
  printf("%s, note is %i\n", task_2.last_status_string(), current_note);
299
 
300
  printf("%s - self object set note to 0xDEADBEEF - ", task_2.name_string());
301
  task_2.set_note(0, 0xDEADBEEF);
302
  printf("%s\n", task_2.last_status_string());
303
 
304
  printf("%s - self object get note - ", task_2.name_string());
305
  task_2.get_note(0, note);
306
  printf("%s, notepad is 0x%08X\n", task_2.last_status_string(), note);
307
 
308
  printf("%s - self object set note to original value - ", task_2.name_string());
309
  task_2.set_note(0, current_note);
310
  printf("%s\n", task_2.last_status_string());
311
 
312
  printf(" * END Task Class test *\n");
313
}
314
 
315
#define RTEMS_ALL_MODES (RTEMS_PREEMPT_MASK | \
316
                         RTEMS_TIMESLICE_MASK | \
317
                         RTEMS_ASR_MASK | \
318
                         RTEMS_INTERRUPT_MASK)
319
 
320
void Task1::screen3(void)
321
{
322
  printf(" * START TaskMode Class test *\n");
323
 
324
  rtemsTask self;
325
  rtemsTaskMode task_mode;
326
  rtems_mode current_mode;
327
  rtems_mode mode;
328
 
329
  printf("%s - get mode - ", self.name_string());
330
  task_mode.get_mode(current_mode);
331
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), current_mode);
332
  print_mode(current_mode, RTEMS_ALL_MODES);
333
  printf("\n");
334
 
335
  // PREEMPTION mode control
336
 
337
  printf("%s - get preemption state - ", self.name_string());
338
  task_mode.get_preemption_state(mode);
339
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
340
  print_mode(mode, RTEMS_PREEMPT_MASK);
341
  printf("\n");
342
 
343
  printf("%s - set preemption state to RTEMS_PREEMPT - ", self.name_string());
344
  task_mode.set_preemption_state(RTEMS_PREEMPT);
345
  task_mode.get_mode(mode);
346
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
347
  print_mode(mode, RTEMS_ALL_MODES);
348
  printf("\n");
349
 
350
  printf("%s - set preemption state to RTEMS_NO_PREEMPT - ", self.name_string());
351
  task_mode.set_preemption_state(RTEMS_NO_PREEMPT);
352
  task_mode.get_mode(mode);
353
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
354
  print_mode(mode, RTEMS_ALL_MODES);
355
  printf("\n");
356
 
357
  // TIMESLICE mode control
358
 
359
  printf("%s - get timeslice state - ", self.name_string());
360
  task_mode.get_timeslice_state(mode);
361
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
362
  print_mode(mode, RTEMS_TIMESLICE_MASK);
363
  printf("\n");
364
 
365
  printf("%s - set timeslice state to RTEMS_TIMESLICE - ", self.name_string());
366
  task_mode.set_timeslice_state(RTEMS_TIMESLICE);
367
  task_mode.get_mode(mode);
368
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
369
  print_mode(mode, RTEMS_ALL_MODES);
370
  printf("\n");
371
 
372
  printf("%s - set timeslice state to RTEMS_NO_TIMESLICE - ", self.name_string());
373
  task_mode.set_timeslice_state(RTEMS_NO_TIMESLICE);
374
  task_mode.get_mode(mode);
375
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
376
  print_mode(mode, RTEMS_ALL_MODES);
377
  printf("\n");
378
 
379
  // ASR mode control
380
 
381
  printf("%s - get asr state - ", self.name_string());
382
  task_mode.get_asr_state(mode);
383
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
384
  print_mode(mode, RTEMS_ASR_MASK);
385
  printf("\n");
386
 
387
  printf("%s - set asr state to RTEMS_ASR - ", self.name_string());
388
  task_mode.set_asr_state(RTEMS_ASR);
389
  task_mode.get_mode(mode);
390
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
391
  print_mode(mode, RTEMS_ALL_MODES);
392
  printf("\n");
393
 
394
  printf("%s - set asr state to RTEMS_NO_ASR - ", self.name_string());
395
  task_mode.set_asr_state(RTEMS_NO_ASR);
396
  task_mode.get_mode(mode);
397
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
398
  print_mode(mode, RTEMS_ALL_MODES);
399
  printf("\n");
400
 
401
  // interrupt level control
402
 
403
  rtems_interrupt_level current_level;
404
  rtems_interrupt_level level;
405
 
406
  printf("%s - get current interrupt level - ", self.name_string());
407
  task_mode.get_interrupt_level(current_level);
408
  printf("%s, level is %i\n", task_mode.last_status_string(), current_level);
409
 
410
  printf("%s - set interrupt level to 102 - ", self.name_string());
411
  task_mode.set_interrupt_level(102);
412
  printf("%s\n", task_mode.last_status_string());
413
 
414
  printf("%s - set interrupt level to original level - ", self.name_string());
415
  task_mode.set_interrupt_level(current_level, level);
416
  printf("%s, level was %i\n", task_mode.last_status_string(), level);
417
 
418
  printf("%s - set mode to original mode - ", self.name_string());
419
  task_mode.set_mode(current_mode,
420
                     RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK |
421
                     RTEMS_ASR_MASK | RTEMS_INTERRUPT_MASK);
422
  task_mode.get_mode(mode);
423
  printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode);
424
  print_mode(mode, RTEMS_ALL_MODES);
425
  printf("\n");
426
 
427
  printf(" * END TaskMode Class test *\n");
428
}
429
 
430
void Task1::screen4(void)
431
{
432
  printf(" * START Event Class test *\n");
433
 
434
  printf("%s - create task 2 - ", name_string());
435
  Task2 task_2("TA2", (rtems_task_priority) 9, RTEMS_MINIMUM_STACK_SIZE * 6);
436
  printf("%s\n", task_2.last_status_string());
437
 
438
  printf("%s - start task 2 - ", name_string());
439
  task_2.start(0);
440
  printf("%s\n", task_2.last_status_string());
441
 
442
  printf("%s - construct event connecting to task 2 - ", name_string());
443
  rtemsEvent event_2("TA2 ");
444
  printf("%s\n", event_2.last_status_string());
445
 
446
  // wait for task 2 to complete its timeout tests
447
  wake_after(7000000);
448
 
449
  printf("%s - send event signal 0 using the task id - ", name_string());
450
  event_2.send(task_2.id_is(), RTEMS_SIGNAL_0);
451
  printf("%s\n", event_2.last_status_string());
452
 
453
  wake_after(1000000);
454
 
455
  printf("%s - send event signal 0 using the task object reference - ", name_string());
456
  event_2.send(task_2, RTEMS_SIGNAL_0);
457
  printf("%s\n", event_2.last_status_string());
458
 
459
  wake_after(1000000);
460
 
461
  printf("%s - send event signal 31 using connected id - ", name_string());
462
  event_2.send(RTEMS_SIGNAL_31);
463
  printf("%s\n", event_2.last_status_string());
464
 
465
  wake_after(1000000);
466
 
467
  rtemsEvent event_2_2;
468
 
469
  event_2_2.connect("TA2");
470
 
471
  printf("%s - send event signal 0 and 31 - ", name_string());
472
  event_2_2.send(task_2, RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31);
473
  printf("%s\n", event_2_2.last_status_string());
474
 
475
  printf("%s - waiting 5 secs for TA2 to finish\n", name_string());
476
  wake_after(500000);
477
 
478
  printf(" * END Event Class test *\n");
479
}
480
 
481
void Task1::screen5(void)
482
{
483
  printf(" * START Interrupt Class test *\n");
484
 
485
  printf(" do not know a portable BSP type interrupt test\n");
486
 
487
  printf(" * END Interrupt Class test *\n");
488
}
489
 
490
void Task1::screen6(void)
491
{
492
  printf(" * START MessageQueue Class test *\n");
493
 
494
  printf("%s - construct message queue 1 with no memory error - ", name_string());
495
  rtemsMessageQueue mq_1("MQ1", 1000000, 1000);
496
  printf("%s\n", mq_1.last_status_string());
497
 
498
  printf("%s - construct/create message queue 2 - ", name_string());
499
  rtemsMessageQueue mq_2("MQ2", 4, 50);
500
  printf("%s\n", mq_2.last_status_string());
501
 
502
  char *u1 = "normal send";
503
  char *u2 = "urgent send";
504
  char in[100];
505
  rtems_unsigned32 size;
506
 
507
  printf("%s - send u1 to mq_2 - ", name_string());
508
  mq_2.send(u1, strlen(u1) + 1);
509
  printf("%s\n", mq_2.last_status_string());
510
 
511
  printf("%s - urgent send u2 to mq_2 - ", name_string());
512
  mq_2.urgent(u2, strlen(u2) + 1);
513
  printf("%s\n", mq_2.last_status_string());
514
 
515
  printf("%s - create task 3_1 - ", name_string());
516
  Task3 task_3_1("TA31", 9, RTEMS_MINIMUM_STACK_SIZE * 6);
517
  printf("%s\n", task_3_1.last_status_string());
518
 
519
  printf("%s - start task 3_1 - ", name_string());
520
  task_3_1.start(0);
521
  printf("%s\n", task_3_1.last_status_string());
522
 
523
  printf("%s - create task 3_2 - ", name_string());
524
  Task3 task_3_2("TA32", 9, RTEMS_MINIMUM_STACK_SIZE * 6);
525
  printf("%s\n", task_3_2.last_status_string());
526
 
527
  printf("%s - start task 3_2 - ", name_string());
528
  task_3_2.start(0);
529
  printf("%s\n", task_3_1.last_status_string());
530
 
531
  wake_after(1000000);
532
 
533
  printf("%s - receive u2 on mq_2 ...\n", name_string()); fflush(stdout);
534
  mq_2.receive(in, size, 5000000);
535
  printf("%s - %s\n", name_string(), mq_2.last_status_string());
536
 
537
  if (size == (strlen(u2) + 5))
538
  {
539
    if ((strncmp(in, task_3_1.name_string(), 4) == 0) &&
540
        (strcmp(in + 4, u2) == 0))
541
    {
542
      printf("%s - message u2 received correctly\n", name_string());
543
    }
544
    else
545
    {
546
      printf("%s - message u2 received incorrectly, message='%s', size=%i\n",
547
             name_string(), in, size);
548
    }
549
  }
550
  else
551
    printf("%s - message u2 size incorrect, size=%i\n", name_string(), size);
552
 
553
  printf("%s - receive u1 on mq_2 ...\n", name_string()); fflush(stdout);
554
  mq_2.receive(in, size, 5000000);
555
  printf("%s - %s\n", name_string(), mq_2.last_status_string());
556
 
557
  if (size == (strlen(u1) + 5))
558
  {
559
    if ((strncmp(in, task_3_2.name_string(), 4) == 0) &&
560
        (strcmp(in + 4, u1) == 0))
561
    {
562
      printf("%s - message u1 received correctly\n", name_string());
563
    }
564
    else
565
    {
566
      printf("%s - message u1 received incorrectly, message='%s', size=%i\n",
567
             name_string(), in, size);
568
    }
569
  }
570
  else
571
    printf("%s - message u1 size incorrect, size=%i\n", name_string(), size);
572
 
573
  wake_after(3000000);
574
 
575
  char *b1 = "broadcast message";
576
  rtems_unsigned32 count;
577
 
578
  printf("%s - broadcast send b1 ...\n", name_string());
579
  mq_2.broadcast(b1, strlen(b1) + 1, count);
580
  printf("%s - mq_2 broadcast send - %s, count=%i\n",
581
         name_string(), mq_2.last_status_string(), count);
582
 
583
  wake_after(1000000);
584
 
585
  printf("%s - receive message b1 on mq_2 from %s...\n",
586
         name_string(), task_3_1.name_string()); fflush(stdout);
587
  mq_2.receive(in, size, 5000000);
588
  printf("%s - %s\n", name_string(), mq_2.last_status_string());
589
 
590
  if (size == (strlen(b1) + 5))
591
  {
592
    if ((strncmp(in, task_3_1.name_string(), 4) == 0) &&
593
        (strcmp(in + 4, b1) == 0))
594
    {
595
      printf("%s - message b1 received correctly\n", name_string());
596
    }
597
    else
598
    {
599
      printf("%s - message b1 received incorrectly, message='%s'\n",
600
             name_string(), in);
601
    }
602
  }
603
  else
604
    printf("%s - message b1 size incorrect, size=%i\n", name_string(), size);
605
 
606
  printf("%s - receive message b1 on mq_2 from %s...\n",
607
         name_string(), task_3_1.name_string()); fflush(stdout);
608
  mq_2.receive(in, size, 5000000);
609
  printf("%s - %s\n", name_string(), mq_2.last_status_string());
610
 
611
  if (size == (strlen(b1) + 5))
612
  {
613
    if ((strncmp(in, task_3_2.name_string(), 4) == 0) &&
614
        (strcmp(in + 4, b1) == 0))
615
    {
616
      printf("%s - message b1 received correctly\n", name_string());
617
    }
618
    else
619
    {
620
      printf("%s - message b1 received incorrectly, message='%s', size=%i\n",
621
             name_string(), in, size);
622
    }
623
  }
624
  else
625
    printf("%s - message b1 size incorrect, size=%i\n", name_string(), size);
626
 
627
  // wait for task 3_1, and 3_2 to complete their timeout tests, will
628
  // start these after getting the broadcast message
629
  wake_after(7000000);
630
 
631
  char *f1 = "flush message";
632
 
633
  printf("%s - send f1 to mq_2 - ", name_string());
634
  mq_2.send(f1, strlen(f1) + 1);
635
  printf("%s\n", mq_2.last_status_string());
636
 
637
  printf("%s - send f1 to mq_2 - ", name_string());
638
  mq_2.send(f1, strlen(f1) + 1);
639
  printf("%s\n", mq_2.last_status_string());
640
 
641
  printf("%s - send f1 to mq_2 - ", name_string());
642
  mq_2.send(f1, strlen(f1) + 1);
643
  printf("%s\n", mq_2.last_status_string());
644
 
645
  printf("%s - flush mq_2 - ", name_string());
646
  mq_2.flush(size);
647
  printf("%s, flushed=%i\n", mq_2.last_status_string(), size);
648
 
649
  printf(" * END MessageQueue Class test *\n");
650
}
651
 
652
void Task1::print_mode(rtems_mode mode, rtems_mode mask)
653
{
654
  rtemsTaskMode task_mode;
655
  if (mask & RTEMS_PREEMPT_MASK)
656
    printf("RTEMS_%sPREEMPT ",
657
           task_mode.preemption_set(mode) ? "" : "NO_");
658
  if (mask & RTEMS_TIMESLICE_MASK)
659
    printf("RTEMS_%sTIMESLICE ",
660
           task_mode.preemption_set(mode) ? "" : "NO_");
661
  if (mask & RTEMS_ASR_MASK)
662
    printf("RTEMS_%sASR ",
663
           task_mode.asr_set(mode) ? "" : "NO_");
664
  if (mask & RTEMS_INTERRUPT_MASK)
665
    printf("INTMASK=%i",
666
           mode & RTEMS_INTERRUPT_MASK);
667
}
668
 
669
EndTask::EndTask(const char* name,
670
                 const rtems_task_priority initial_priority,
671
                 const rtems_unsigned32 stack_size)
672
  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
673
{
674
}
675
 
676
void EndTask::body(rtems_task_argument)
677
{
678
 printf("*** END OF RTEMS++ TEST ***\n");
679
 exit(0);
680
}
681
 

powered by: WebSVN 2.1.0

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