source: rtems/testsuites/libtests/rtems++/Task3.cc @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*  Task_3
2 *
3 *  This routine serves as a test task. Loopback the messages and test
4 *  timeouts
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1998.
12 *  On-Line Applications Research Corporation (OAR).
13 *  Copyright assigned to U.S. Government, 1994.
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.OARcorp.com/rtems/license.html.
18 *
19 *  $Id$
20 */
21
22#include "System.h"
23
24Task3::Task3(const char* name,
25             const rtems_task_priority initial_priority,
26             const rtems_unsigned32 stack_size)
27  : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT)
28{
29}
30 
31void Task3::body(rtems_task_argument )
32{
33  screen6();
34
35  printf("%s - destroy itself\n", name_string());
36  destroy();
37}
38
39void Task3::screen6()
40{
41  rtemsMessageQueue mq_2("MQ2");
42  printf("%s - construction connect mq_2 - %s\n", name_string(), mq_2.last_status_string());
43
44  if (mq_2.successful())
45  {
46    char in[100];
47    char out[100];
48    rtems_unsigned32 size;
49    bool loopback = true;
50 
51    while (loopback)
52    {
53    printf("%s - loopback from mq_2 to mq_2 ...\n", name_string()); fflush(stdout);
54
55    mq_2.receive(in, size);
56      printf("%s - mq_2 receive - %s, size=%i, message string size=%i\n",
57             name_string(), mq_2.last_status_string(), size, (int) strlen(in));
58      if (mq_2.successful())
59      {
60        if (size > (100 - 5))
61          printf("%s - size to large\n", name_string());
62        else
63        {
64          strcpy(out, name_string());
65          strcpy(out + 4, in);
66     
67          printf("%s - loopback to mq_2 - ", name_string());
68          mq_2.send(out, strlen(out) + 1);
69          printf("%s\n", mq_2.last_status_string());
70        }
71
72        if (strcmp(in, "broadcast message") == 0)
73          loopback = false;
74        else
75          wake_after(1500000);
76      }
77    }
78  }
79}
80
81
Note: See TracBrowser for help on using the repository browser.