source: rtems/testsuites/mptests/mp10/init.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization routine for this test program.
4 *  Other than creating all objects needed by this test, if this routine
5 *  is running on node one, it acquires a global semaphore to
6 *  force all other tasks to pend.  If running on node two, this task
7 *  sleeps for a while, and then deletes two local tasks which are
8 *  waiting on a remote message queue or a semaphore.
9 *  This routine is the initialization task for this test program.
10 *  It is a user initialization task and has the responsibility for creating
11 *  and starting the tasks that make up the test.  If the time of day
12 *  clock is required for the test, it should also be set to a known
13 *  value by this function.
14 *
15 *  Input parameters:
16 *    argument - task argument
17 *
18 *  Output parameters:  NONE
19 *
20 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
21 *  On-Line Applications Research Corporation (OAR).
22 *  All rights assigned to U.S. Government, 1994.
23 *
24 *  This material may be reproduced by or for the U.S. Government pursuant
25 *  to the copyright license under the clause at DFARS 252.227-7013.  This
26 *  notice must appear in all copies of this file and its derivatives.
27 *
28 *  $Id$
29 */
30
31#include "system.h"
32#undef EXTERN
33#define EXTERN
34#include "conftbl.h"
35#include "gvar.h"
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  rtems_status_code status;
42
43  printf(
44   "\n\n*** TEST 10 -- NODE %d ***\n",
45   Multiprocessing_configuration.node
46  );
47
48  Task_name[ 1 ] =  rtems_build_name( 'T', 'A', '1', ' ' );
49  Task_name[ 2 ] =  rtems_build_name( 'T', 'A', '2', ' ' );
50  Task_name[ 3 ] =  rtems_build_name( 'S', 'A', '3', ' ' );
51
52  Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' );
53
54  Semaphore_name[ 1 ] = rtems_build_name( 'S', 'E', 'M', ' ' );
55
56  if ( Multiprocessing_configuration.node == 1 ) {
57    puts( "Creating Message Queue (Global)" );
58    status = rtems_message_queue_create(
59      Queue_name[ 1 ],
60      3,
61      RTEMS_GLOBAL|RTEMS_LIMIT,
62      &Queue_id[ 1 ]
63    );
64    directive_failed( status, "rtems_message_queue_create" );
65
66    puts( "Creating Semaphore (Global)" );
67    status = rtems_semaphore_create(
68      Semaphore_name[ 1 ],
69      0,
70      RTEMS_GLOBAL | RTEMS_PRIORITY,
71      &Semaphore_id[ 1 ]
72    );
73    directive_failed( status, "rtems_semaphore_create" );
74
75    status = rtems_task_wake_after( 10 * TICKS_PER_SECOND );
76    directive_failed( status, "rtems_task_wake_after" );
77
78  } else {
79
80    puts( "Creating Test_task 1 (local)" );
81    status = rtems_task_create(
82      Task_name[ 1 ],
83      1,
84      1024,
85      RTEMS_TIMESLICE,
86      RTEMS_DEFAULT_ATTRIBUTES,
87      &Task_id[ 1 ]
88    );
89    directive_failed( status, "rtems_task_create" );
90
91    puts( "Starting Test_task 1 (local)" );
92    status = rtems_task_start( Task_id[ 1 ], Test_task1, 0 );
93    directive_failed( status, "rtems_task_start" );
94
95    puts( "Creating Test_task 2 (local)" );
96    status = rtems_task_create(
97      Task_name[ 2 ],
98      1,
99      1024,
100      RTEMS_TIMESLICE,
101      RTEMS_DEFAULT_ATTRIBUTES,
102      &Task_id[ 2 ]
103    );
104    directive_failed( status, "rtems_task_create" );
105
106    puts( "Starting Test_task 2 (local)" );
107    status = rtems_task_start( Task_id[ 2 ], Test_task2, 0 );
108    directive_failed( status, "rtems_task_start" );
109
110    puts( "Creating Test_task 3 (local)" );
111    status = rtems_task_create(
112      Task_name[ 3 ],
113      1,
114      1024,
115      RTEMS_TIMESLICE,
116      RTEMS_DEFAULT_ATTRIBUTES,
117      &Task_id[ 3 ]
118    );
119    directive_failed( status, "rtems_task_create" );
120
121    puts( "Starting Test_task 3 (local)" );
122    status = rtems_task_start( Task_id[ 3 ], Test_task2, 0 );
123    directive_failed( status, "rtems_task_start" );
124
125    puts( "Sleeping for 1 seconds ..." );
126    status = rtems_task_wake_after( TICKS_PER_SECOND );
127    directive_failed( status, "rtems_task_wake_after" );
128
129    puts( "Deleting Test_task2" );
130    status = rtems_task_delete( Task_id[ 2 ] );
131    directive_failed( status, "rtems_task_delete of Task 2" );
132
133    puts( "Deleting Test_task1" );
134    status = rtems_task_delete( Task_id[ 1 ] );
135    directive_failed( status, "rtems_task_delete of Task 1" );
136
137    puts( "Restarting Test_task3" );
138    status = rtems_task_restart( Task_id[ 3 ], 1 );
139    directive_failed( status, "rtems_task_restart of Task 3" );
140
141  }
142  puts( "*** END OF TEST 10 ***" );
143  exit( 0 );
144}
Note: See TracBrowser for help on using the repository browser.