source: rtems/testsuites/mptests/mp10/init.c @ 3235ad9

4.104.114.84.95
Last change on this file since 3235ad9 was 3235ad9, checked in by Joel Sherrill <joel.sherrill@…>, on 08/23/95 at 19:30:23

Support for variable length names added to Object Handler. This supports
both fixed length "raw" names and strings from the API's point of view.

Both inline and macro implementations were tested.

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[ac7d5ef0]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 *
[3235ad9]28 *  $Id$
[ac7d5ef0]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,
[4b374f36]61      16,
62      RTEMS_GLOBAL,
[ac7d5ef0]63      &Queue_id[ 1 ]
64    );
65    directive_failed( status, "rtems_message_queue_create" );
66
67    puts( "Creating Semaphore (Global)" );
68    status = rtems_semaphore_create(
69      Semaphore_name[ 1 ],
70      0,
71      RTEMS_GLOBAL | RTEMS_PRIORITY,
72      &Semaphore_id[ 1 ]
73    );
74    directive_failed( status, "rtems_semaphore_create" );
75
76    status = rtems_task_wake_after( 10 * TICKS_PER_SECOND );
77    directive_failed( status, "rtems_task_wake_after" );
78
79  } else {
80
81    puts( "Creating Test_task 1 (local)" );
82    status = rtems_task_create(
83      Task_name[ 1 ],
84      1,
85      1024,
86      RTEMS_TIMESLICE,
87      RTEMS_DEFAULT_ATTRIBUTES,
88      &Task_id[ 1 ]
89    );
90    directive_failed( status, "rtems_task_create" );
91
92    puts( "Starting Test_task 1 (local)" );
93    status = rtems_task_start( Task_id[ 1 ], Test_task1, 0 );
94    directive_failed( status, "rtems_task_start" );
95
96    puts( "Creating Test_task 2 (local)" );
97    status = rtems_task_create(
98      Task_name[ 2 ],
99      1,
100      1024,
101      RTEMS_TIMESLICE,
102      RTEMS_DEFAULT_ATTRIBUTES,
103      &Task_id[ 2 ]
104    );
105    directive_failed( status, "rtems_task_create" );
106
107    puts( "Starting Test_task 2 (local)" );
108    status = rtems_task_start( Task_id[ 2 ], Test_task2, 0 );
109    directive_failed( status, "rtems_task_start" );
110
111    puts( "Creating Test_task 3 (local)" );
112    status = rtems_task_create(
113      Task_name[ 3 ],
114      1,
115      1024,
116      RTEMS_TIMESLICE,
117      RTEMS_DEFAULT_ATTRIBUTES,
118      &Task_id[ 3 ]
119    );
120    directive_failed( status, "rtems_task_create" );
121
122    puts( "Starting Test_task 3 (local)" );
123    status = rtems_task_start( Task_id[ 3 ], Test_task2, 0 );
124    directive_failed( status, "rtems_task_start" );
125
126    puts( "Sleeping for 1 seconds ..." );
127    status = rtems_task_wake_after( TICKS_PER_SECOND );
128    directive_failed( status, "rtems_task_wake_after" );
129
130    puts( "Deleting Test_task2" );
131    status = rtems_task_delete( Task_id[ 2 ] );
132    directive_failed( status, "rtems_task_delete of Task 2" );
133
134    puts( "Deleting Test_task1" );
135    status = rtems_task_delete( Task_id[ 1 ] );
136    directive_failed( status, "rtems_task_delete of Task 1" );
137
138    puts( "Restarting Test_task3" );
139    status = rtems_task_restart( Task_id[ 3 ], 1 );
140    directive_failed( status, "rtems_task_restart of Task 3" );
141
142  }
143  puts( "*** END OF TEST 10 ***" );
144  exit( 0 );
145}
Note: See TracBrowser for help on using the repository browser.