source: rtems/testsuites/mptests/mp07/task1.c @ a319ebef

4.104.114.9
Last change on this file since a319ebef was a319ebef, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 5, 2008 at 2:41:37 PM

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • mp03/delay.c, mp06/task1.c, mp06/node2/mp06-node2.scn, mp07/task1.c: Updating and fixing while running them on psim.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*  Test_task
2 *
3 *  This task continuously sends an event to its counterpart on the
4 *  other node, and then waits for it to send an event.  The copy
5 *  running on node one send the first event.
6 *
7 *  Input parameters:
8 *    argument - task argument
9 *
10 *  Output parameters:  NONE
11 *
12 *  COPYRIGHT (c) 1989-1999.
13 *  On-Line Applications Research Corporation (OAR).
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.rtems.com/license/LICENSE.
18 *
19 *  $Id$
20 */
21
22#include "system.h"
23
24#define DOT_COUNT 100
25
26rtems_timer_service_routine Stop_Test_TSR(
27  rtems_id  ignored_id,
28  void     *ignored_address
29)
30{
31  Stop_Test = true;
32}
33
34rtems_task Test_task(
35  rtems_task_argument argument
36)
37{
38  rtems_status_code status;
39  uint32_t    count;
40  uint32_t    remote_node;
41  rtems_id          remote_tid;
42  rtems_event_set   event_out;
43
44  Stop_Test = false;
45
46  remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1;
47  puts_nocr( "Remote task's name is : " );
48  put_name( Task_name[ remote_node ], TRUE );
49
50  puts( "Getting TID of remote task" );
51  do {
52    status = rtems_task_ident(
53      Task_name[ remote_node ],
54      RTEMS_SEARCH_ALL_NODES,
55      &remote_tid
56    );
57  } while ( !rtems_is_status_successful( status ) );
58
59  if ( Multiprocessing_configuration.node == 1 ) {
60    puts( "Sending first event to remote task" );
61    status = rtems_event_send( remote_tid, RTEMS_EVENT_16 );
62    directive_failed( status, "rtems_event_send" );
63  }
64
65  status = rtems_timer_fire_after(
66    Timer_id[ 1 ],
67    5 * TICKS_PER_SECOND,
68    Stop_Test_TSR,
69    NULL
70  );
71  directive_failed( status, "rtems_timer_fire_after" );
72
73  while ( true ) {
74    for ( count=DOT_COUNT ; count && (Stop_Test == false) ; count-- ) {
75      status = rtems_event_receive(
76        RTEMS_EVENT_16,
77        RTEMS_DEFAULT_OPTIONS,
78        TICKS_PER_SECOND,
79        &event_out
80      );
81      if ( status == RTEMS_TIMEOUT ) {
82        printf("\nTA1 - RTEMS_TIMEOUT .. probably OK if the other node exits");
83        Stop_Test = true;
84        break;
85      } else
86        directive_failed( status, "rtems_event_receive" );
87
88      status = rtems_event_send( remote_tid, RTEMS_EVENT_16 );
89      directive_failed( status, "rtems_event_send" );
90    }
91    if ( Stop_Test )
92       break;
93    put_dot('.');
94  }
95
96  /*
97   * Wait a bit before shutting down so we don't screw up the other node
98   * when our MPCI shuts down
99   */
100
101  rtems_task_wake_after(10);
102
103  puts( "\n*** END OF TEST 7 ***" );
104  rtems_test_exit( 0 );
105}
Note: See TracBrowser for help on using the repository browser.