source: rtems/testsuites/mptests/mp03/task1.c @ 03f2154e

4.104.114.84.95
Last change on this file since 03f2154e was 03f2154e, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 22, 1997 at 5:20:27 PM

headers updated to reflect new style copyright notice as part
of switching to the modified GNU GPL.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*  Test_task
2 *
3 *  This task suspends and resumes a remote task.
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1997.
11 *  On-Line Applications Research Corporation (OAR).
12 *  Copyright assigned to U.S. Government, 1994.
13 *
14 *  The license and distribution terms for this file may in
15 *  the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23/*PAGE
24 *
25 *  Test_Task_Support
26 *
27 */
28
29void Test_Task_Support(
30  rtems_unsigned32  node
31)
32{
33  rtems_event_set   events;
34  rtems_status_code status;
35
36  if ( Multiprocessing_configuration.node == node ) {
37
38    for ( ; ; ) {
39
40      status = rtems_event_receive(
41        RTEMS_EVENT_16,
42        RTEMS_NO_WAIT,
43        RTEMS_NO_TIMEOUT,
44        &events
45      );
46
47      if ( status == RTEMS_SUCCESSFUL )
48        break;
49
50      fatal_directive_status(status, RTEMS_UNSATISFIED, "rtems_event_receive");
51
52      status = rtems_task_wake_after( 2 * TICKS_PER_SECOND );
53      directive_failed( status, "rtems_task_wake_after" );
54
55      put_name( Task_name[ node ], FALSE );
56      puts( " - Suspending remote task" );
57
58      status = rtems_task_suspend( remote_tid );
59      directive_failed( status, "rtems_task_suspend" );
60
61      status = rtems_task_wake_after( 2 * TICKS_PER_SECOND );
62      directive_failed( status, "rtems_task_wake_after" );
63
64      put_name( Task_name[ node ], FALSE );
65      puts( " - Resuming remote task" );
66
67      status = rtems_task_resume( remote_tid ) ;
68      directive_failed( status, "rtems_task_resume" );
69
70    }
71
72  }  else {
73
74    for ( ; ; ) {
75      status = rtems_event_receive(
76        RTEMS_EVENT_16,
77        RTEMS_NO_WAIT,
78        RTEMS_NO_TIMEOUT,
79        &events
80      );
81
82      if ( status == RTEMS_SUCCESSFUL )
83        break;
84
85      fatal_directive_status(status, RTEMS_UNSATISFIED, "rtems_event_receive");
86
87      put_name( Task_name[ remote_node ], FALSE );
88      puts( " - have I been suspended???" );
89
90      status = rtems_task_wake_after( TICKS_PER_SECOND / 2 );
91      directive_failed( status, "rtems_task_wake_after" );
92    }
93
94  }
95
96}
97
98/*PAGE
99 *
100 *  Test_task
101 */
102
103rtems_task Test_task(
104  rtems_task_argument argument
105)
106{
107  rtems_id          tid;
108  rtems_status_code status;
109
110  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
111  directive_failed( status, "rtems_task_ident" );
112
113  puts( "Getting TID of remote task" );
114  remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1;
115  printf( "Remote task's name is : " );
116  put_name( Task_name[ remote_node ], TRUE );
117
118  do {
119      status = rtems_task_ident(
120          Task_name[ remote_node ],
121          RTEMS_SEARCH_ALL_NODES,
122          &remote_tid
123          );
124  } while ( status != RTEMS_SUCCESSFUL );
125
126  directive_failed( status, "rtems_task_ident" );
127
128  status = rtems_timer_fire_after(
129    Timer_id[ 1 ],
130    5 * TICKS_PER_SECOND,
131    Delayed_send_event,
132    NULL
133  );
134  directive_failed( status, "rtems_timer_fire_after" );
135
136  Test_Task_Support( 1 );
137
138  status = rtems_timer_fire_after(
139    Timer_id[ 1 ],
140    5 * TICKS_PER_SECOND,
141    Delayed_send_event,
142    NULL
143  );
144  directive_failed( status, "rtems_timer_fire_after" );
145
146  if ( Multiprocessing_configuration.node == 1 ) {
147    status = rtems_task_wake_after( 2 * TICKS_PER_SECOND );
148    directive_failed( status, "rtems_task_wake_after" );
149  }
150
151  Test_Task_Support( 2 );
152
153  puts( "*** END OF TEST 3 ***" );
154  exit( 0 );
155}
Note: See TracBrowser for help on using the repository browser.