source: rtems/c/src/tests/mptests/mp10/init.c @ 3652ad35

4.104.114.84.95
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on 09/19/95 at 14:53:29

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

  • Property mode set to 100644
File size: 4.3 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#define TEST_INIT
32#include "system.h"
33
34rtems_task Init(
35  rtems_task_argument argument
36)
37{
38  rtems_status_code status;
39
40  printf(
41   "\n\n*** TEST 10 -- NODE %d ***\n",
42   Multiprocessing_configuration.node
43  );
44
45  Task_name[ 1 ] =  rtems_build_name( 'T', 'A', '1', ' ' );
46  Task_name[ 2 ] =  rtems_build_name( 'T', 'A', '2', ' ' );
47  Task_name[ 3 ] =  rtems_build_name( 'S', 'A', '3', ' ' );
48
49  Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' );
50
51  Semaphore_name[ 1 ] = rtems_build_name( 'S', 'E', 'M', ' ' );
52
53  if ( Multiprocessing_configuration.node == 1 ) {
54    puts( "Creating Message Queue (Global)" );
55    status = rtems_message_queue_create(
56      Queue_name[ 1 ],
57      3,
58      16,
59      RTEMS_GLOBAL,
60      &Queue_id[ 1 ]
61    );
62    directive_failed( status, "rtems_message_queue_create" );
63
64    puts( "Creating Semaphore (Global)" );
65    status = rtems_semaphore_create(
66      Semaphore_name[ 1 ],
67      0,
68      RTEMS_GLOBAL | RTEMS_PRIORITY,
69      RTEMS_NO_PRIORITY,
70      &Semaphore_id[ 1 ]
71    );
72    directive_failed( status, "rtems_semaphore_create" );
73
74    status = rtems_task_wake_after( 10 * TICKS_PER_SECOND );
75    directive_failed( status, "rtems_task_wake_after" );
76
77  } else {
78
79    puts( "Creating Test_task 1 (local)" );
80    status = rtems_task_create(
81      Task_name[ 1 ],
82      1,
83      RTEMS_MINIMUM_STACK_SIZE,
84      RTEMS_TIMESLICE,
85      RTEMS_DEFAULT_ATTRIBUTES,
86      &Task_id[ 1 ]
87    );
88    directive_failed( status, "rtems_task_create" );
89
90    puts( "Starting Test_task 1 (local)" );
91    status = rtems_task_start( Task_id[ 1 ], Test_task1, 0 );
92    directive_failed( status, "rtems_task_start" );
93
94    puts( "Creating Test_task 2 (local)" );
95    status = rtems_task_create(
96      Task_name[ 2 ],
97      1,
98      RTEMS_MINIMUM_STACK_SIZE,
99      RTEMS_TIMESLICE,
100      RTEMS_DEFAULT_ATTRIBUTES,
101      &Task_id[ 2 ]
102    );
103    directive_failed( status, "rtems_task_create" );
104
105    puts( "Starting Test_task 2 (local)" );
106    status = rtems_task_start( Task_id[ 2 ], Test_task2, 0 );
107    directive_failed( status, "rtems_task_start" );
108
109    puts( "Creating Test_task 3 (local)" );
110    status = rtems_task_create(
111      Task_name[ 3 ],
112      1,
113      RTEMS_MINIMUM_STACK_SIZE,
114      RTEMS_TIMESLICE,
115      RTEMS_DEFAULT_ATTRIBUTES,
116      &Task_id[ 3 ]
117    );
118    directive_failed( status, "rtems_task_create" );
119
120    puts( "Starting Test_task 3 (local)" );
121    status = rtems_task_start( Task_id[ 3 ], Test_task2, 0 );
122    directive_failed( status, "rtems_task_start" );
123
124    puts( "Sleeping for 1 seconds ..." );
125    status = rtems_task_wake_after( TICKS_PER_SECOND );
126    directive_failed( status, "rtems_task_wake_after" );
127
128    puts( "Deleting Test_task2" );
129    status = rtems_task_delete( Task_id[ 2 ] );
130    directive_failed( status, "rtems_task_delete of Task 2" );
131
132    puts( "Deleting Test_task1" );
133    status = rtems_task_delete( Task_id[ 1 ] );
134    directive_failed( status, "rtems_task_delete of Task 1" );
135
136    puts( "Restarting Test_task3" );
137    status = rtems_task_restart( Task_id[ 3 ], 1 );
138    directive_failed( status, "rtems_task_restart of Task 3" );
139
140  }
141  puts( "*** END OF TEST 10 ***" );
142  exit( 0 );
143}
Note: See TracBrowser for help on using the repository browser.