From ac7d5ef06a6d6e8d84abbd1f0b82162725f98326 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 11 May 1995 17:39:37 +0000 Subject: Initial revision --- testsuites/mptests/mp06/task1.c | 176 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 testsuites/mptests/mp06/task1.c (limited to 'testsuites/mptests/mp06/task1.c') diff --git a/testsuites/mptests/mp06/task1.c b/testsuites/mptests/mp06/task1.c new file mode 100644 index 0000000000..5b63a9ff76 --- /dev/null +++ b/testsuites/mptests/mp06/task1.c @@ -0,0 +1,176 @@ +/* Test_task + * + * This task tests global event operations. If running on node one, it + * continuously sends events. If running on node two, it continuously + * receives events. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include "system.h" + +#define DOT_COUNT 25 + +/*PAGE + * + * Stop_Test_TSR + */ + +rtems_timer_service_routine Stop_Test_TSR( + rtems_id ignored_id, + void *ignored_address +) +{ + Stop_Test = TRUE; +} + +/*PAGE + * + * Event_set_table + */ + +rtems_event_set Event_set_table[] = { + RTEMS_EVENT_0, + RTEMS_EVENT_1, + RTEMS_EVENT_2, + RTEMS_EVENT_3, + RTEMS_EVENT_4, + RTEMS_EVENT_5, + RTEMS_EVENT_6, + RTEMS_EVENT_7, + RTEMS_EVENT_8, + RTEMS_EVENT_9, + RTEMS_EVENT_10, + RTEMS_EVENT_11, + RTEMS_EVENT_12, + RTEMS_EVENT_13, + RTEMS_EVENT_14, + RTEMS_EVENT_15, + RTEMS_EVENT_16, + RTEMS_EVENT_17, + RTEMS_EVENT_18, + RTEMS_EVENT_19, + RTEMS_EVENT_20, + RTEMS_EVENT_21, + RTEMS_EVENT_22, + RTEMS_EVENT_23, + RTEMS_EVENT_24, + RTEMS_EVENT_25, + RTEMS_EVENT_26, + RTEMS_EVENT_27, + RTEMS_EVENT_28, + RTEMS_EVENT_29, + RTEMS_EVENT_30, + RTEMS_EVENT_31 +}; + +/*PAGE + * + * Test_task + */ + +rtems_task Test_task( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_unsigned32 count; + rtems_unsigned32 remote_node; + rtems_id remote_tid; + rtems_event_set event_out; + rtems_event_set event_for_this_iteration; + + Stop_Test = FALSE; + + remote_node = (Multiprocessing_configuration.node == 1) ? 2 : 1; + puts_nocr( "Remote task's name is : " ); + put_name( Task_name[ remote_node ], TRUE ); + + puts( "Getting TID of remote task" ); + do { + status = rtems_task_ident( + Task_name[ remote_node ], + RTEMS_SEARCH_ALL_NODES, + &remote_tid + ); + } while ( status != RTEMS_SUCCESSFUL ); + directive_failed( status, "rtems_task_ident FAILED!!" ); + + if ( Multiprocessing_configuration.node == 1 ) + puts( "Sending events to remote task" ); + else + puts( "Receiving events from remote task" ); + + status = rtems_timer_fire_after( + Timer_id[ 1 ], + 5 * TICKS_PER_SECOND, + Stop_Test_TSR, + NULL + ); + directive_failed( status, "rtems_timer_fire_after" ); + + count = 0; + + for ( ; ; ) { + if ( Stop_Test == TRUE ) + break; + + event_for_this_iteration = Event_set_table[ count % 32 ]; + + if ( Multiprocessing_configuration.node == 1 ) { + status = rtems_event_send( remote_tid, event_for_this_iteration ); + directive_failed( status, "rtems_event_send" ); + + status = rtems_task_wake_after( 1 ); + directive_failed( status, "rtems_task_wake_after" ); + } else { + status = rtems_event_receive( + event_for_this_iteration, + RTEMS_DEFAULT_OPTIONS, + 1 * TICKS_PER_SECOND, + &event_out + ); + if ( rtems_are_statuses_equal( status, RTEMS_TIMEOUT ) ) { + if ( Multiprocessing_configuration.node == 2 ) + puts( "\nCorrect behavior if the other node exitted." ); + else + puts( "\nERROR... node 1 died" ); + break; + } else + directive_failed( status, "rtems_event_receive" ); + } + + if ( (count % DOT_COUNT) == 0 ) + put_dot('.'); + + count++; + } + + putchar( '\n' ); + + if ( Multiprocessing_configuration.node == 2 ) { + status = rtems_event_receive( + RTEMS_EVENT_16, + RTEMS_DEFAULT_OPTIONS, + 1 * TICKS_PER_SECOND, + &event_out + ); + fatal_directive_status( status, RTEMS_TIMEOUT, "rtems_event_receive" ); + puts( "rtems_event_receive - correctly returned RTEMS_TIMEOUT" ); + } + puts( "*** END OF TEST 6 ***" ); + exit( 0 ); +} -- cgit v1.2.3