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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [mptests/] [mp06/] [task1.c] - Blame information for rev 507

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

Line No. Rev Author Line
1 30 unneback
/*  Test_task
2
 *
3
 *  This task tests global event operations.  If running on node one, it
4
 *  continuously sends events.   If running on node two, it continuously
5
 *  receives events.
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.OARcorp.com/rtems/license.html.
18
 *
19
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:18 chris Exp $
20
 */
21
 
22
#include "system.h"
23
 
24
#define DOT_COUNT 25
25
 
26
/*PAGE
27
 *
28
 *  Stop_Test_TSR
29
 */
30
 
31
rtems_timer_service_routine Stop_Test_TSR(
32
  rtems_id  ignored_id,
33
  void     *ignored_address
34
)
35
{
36
  Stop_Test = TRUE;
37
}
38
 
39
/*PAGE
40
 *
41
 *  Event_set_table
42
 */
43
 
44
rtems_event_set Event_set_table[] = {
45
  RTEMS_EVENT_0,
46
  RTEMS_EVENT_1,
47
  RTEMS_EVENT_2,
48
  RTEMS_EVENT_3,
49
  RTEMS_EVENT_4,
50
  RTEMS_EVENT_5,
51
  RTEMS_EVENT_6,
52
  RTEMS_EVENT_7,
53
  RTEMS_EVENT_8,
54
  RTEMS_EVENT_9,
55
  RTEMS_EVENT_10,
56
  RTEMS_EVENT_11,
57
  RTEMS_EVENT_12,
58
  RTEMS_EVENT_13,
59
  RTEMS_EVENT_14,
60
  RTEMS_EVENT_15,
61
  RTEMS_EVENT_16,
62
  RTEMS_EVENT_17,
63
  RTEMS_EVENT_18,
64
  RTEMS_EVENT_19,
65
  RTEMS_EVENT_20,
66
  RTEMS_EVENT_21,
67
  RTEMS_EVENT_22,
68
  RTEMS_EVENT_23,
69
  RTEMS_EVENT_24,
70
  RTEMS_EVENT_25,
71
  RTEMS_EVENT_26,
72
  RTEMS_EVENT_27,
73
  RTEMS_EVENT_28,
74
  RTEMS_EVENT_29,
75
  RTEMS_EVENT_30,
76
  RTEMS_EVENT_31
77
};
78
 
79
/*PAGE
80
 *
81
 *  Test_task
82
 */
83
 
84
rtems_task Test_task(
85
  rtems_task_argument argument
86
)
87
{
88
  rtems_status_code status;
89
  rtems_unsigned32  count;
90
  rtems_unsigned32  remote_node;
91
  rtems_id          remote_tid;
92
  rtems_event_set   event_out;
93
  rtems_event_set   event_for_this_iteration;
94
 
95
  Stop_Test = FALSE;
96
 
97
  remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1;
98
  puts_nocr( "Remote task's name is : " );
99
  put_name( Task_name[ remote_node ], TRUE );
100
 
101
  puts( "Getting TID of remote task" );
102
  do {
103
      status = rtems_task_ident(
104
          Task_name[ remote_node ],
105
          RTEMS_SEARCH_ALL_NODES,
106
          &remote_tid
107
          );
108
  } while ( status != RTEMS_SUCCESSFUL );
109
  directive_failed( status, "rtems_task_ident FAILED!!" );
110
 
111
  if ( Multiprocessing_configuration.node == 1 )
112
    puts( "Sending events to remote task" );
113
  else
114
    puts( "Receiving events from remote task" );
115
 
116
  status = rtems_timer_fire_after(
117
    Timer_id[ 1 ],
118
    5 * TICKS_PER_SECOND,
119
    Stop_Test_TSR,
120
    NULL
121
  );
122
  directive_failed( status, "rtems_timer_fire_after" );
123
 
124
  count = 0;
125
 
126
  for ( ; ; ) {
127
    if ( Stop_Test == TRUE )
128
      break;
129
 
130
    event_for_this_iteration = Event_set_table[ count % 32 ];
131
 
132
    if ( Multiprocessing_configuration.node == 1 ) {
133
      status = rtems_event_send( remote_tid, event_for_this_iteration );
134
      directive_failed( status, "rtems_event_send" );
135
 
136
      status = rtems_task_wake_after( 1 );
137
      directive_failed( status, "rtems_task_wake_after" );
138
    } else {
139
      status = rtems_event_receive(
140
        event_for_this_iteration,
141
        RTEMS_DEFAULT_OPTIONS,
142
        1 * TICKS_PER_SECOND,
143
        &event_out
144
      );
145
      if ( rtems_are_statuses_equal( status, RTEMS_TIMEOUT ) ) {
146
        if ( Multiprocessing_configuration.node == 2 )
147
          puts( "\nCorrect behavior if the other node exitted." );
148
        else
149
          puts( "\nERROR... node 1 died" );
150
        break;
151
      } else
152
        directive_failed( status, "rtems_event_receive" );
153
    }
154
 
155
    if ( (count % DOT_COUNT) == 0 )
156
      put_dot('.');
157
 
158
    count++;
159
  }
160
 
161
  putchar( '\n' );
162
 
163
  if ( Multiprocessing_configuration.node == 2 ) {
164
    status = rtems_event_receive(
165
      RTEMS_EVENT_16,
166
      RTEMS_DEFAULT_OPTIONS,
167
      1 * TICKS_PER_SECOND,
168
      &event_out
169
    );
170
    fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_event_receive" );
171
    puts( "rtems_event_receive - correctly returned RTEMS_TIMEOUT" );
172
  }
173
  puts( "*** END OF TEST 6 ***" );
174
  exit( 0 );
175
}

powered by: WebSVN 2.1.0

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