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

4.115
Last change on this file since a4bc4d6e was a4bc4d6e, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/22/11 at 10:00:39

Add HAVE_CONFIG_H.

  • 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-2009.
21 *  On-Line Applications Research Corporation (OAR).
22 *
23 *  The license and distribution terms for this file may be
24 *  found in the file LICENSE in this distribution or at
25 *  http://www.rtems.com/license/LICENSE.
26 *
27 *  $Id$
28 */
29
30#ifdef HAVE_CONFIG_H
31#include "config.h"
32#endif
33
34#define CONFIGURE_INIT
35#include "system.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 %" PRIu32 " ***\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      16,
62      RTEMS_GLOBAL,
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      RTEMS_NO_PRIORITY,
73      &Semaphore_id[ 1 ]
74    );
75    directive_failed( status, "rtems_semaphore_create" );
76
77    status = rtems_task_wake_after( 10 * rtems_clock_get_ticks_per_second() );
78    directive_failed( status, "rtems_task_wake_after" );
79
80  } else {
81
82    puts( "Creating Test_task 1 (local)" );
83    status = rtems_task_create(
84      Task_name[ 1 ],
85      1,
86      RTEMS_MINIMUM_STACK_SIZE,
87      RTEMS_TIMESLICE,
88      RTEMS_DEFAULT_ATTRIBUTES,
89      &Task_id[ 1 ]
90    );
91    directive_failed( status, "rtems_task_create" );
92
93    puts( "Starting Test_task 1 (local)" );
94    status = rtems_task_start( Task_id[ 1 ], Test_task1, 0 );
95    directive_failed( status, "rtems_task_start" );
96
97    puts( "Creating Test_task 2 (local)" );
98    status = rtems_task_create(
99      Task_name[ 2 ],
100      1,
101      RTEMS_MINIMUM_STACK_SIZE,
102      RTEMS_TIMESLICE,
103      RTEMS_DEFAULT_ATTRIBUTES,
104      &Task_id[ 2 ]
105    );
106    directive_failed( status, "rtems_task_create" );
107
108    puts( "Starting Test_task 2 (local)" );
109    status = rtems_task_start( Task_id[ 2 ], Test_task2, 0 );
110    directive_failed( status, "rtems_task_start" );
111
112    puts( "Creating Test_task 3 (local)" );
113    status = rtems_task_create(
114      Task_name[ 3 ],
115      1,
116      RTEMS_MINIMUM_STACK_SIZE,
117      RTEMS_TIMESLICE,
118      RTEMS_DEFAULT_ATTRIBUTES,
119      &Task_id[ 3 ]
120    );
121    directive_failed( status, "rtems_task_create" );
122
123    puts( "Starting Test_task 3 (local)" );
124    status = rtems_task_start( Task_id[ 3 ], Test_task2, 0 );
125    directive_failed( status, "rtems_task_start" );
126
127    puts( "Sleeping for 1 seconds ..." );
128    status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
129    directive_failed( status, "rtems_task_wake_after" );
130
131    puts( "Deleting Test_task2" );
132    status = rtems_task_delete( Task_id[ 2 ] );
133    directive_failed( status, "rtems_task_delete of Task 2" );
134
135    puts( "Deleting Test_task1" );
136    status = rtems_task_delete( Task_id[ 1 ] );
137    directive_failed( status, "rtems_task_delete of Task 1" );
138
139    puts( "Restarting Test_task3" );
140    status = rtems_task_restart( Task_id[ 3 ], 1 );
141    directive_failed( status, "rtems_task_restart of Task 3" );
142
143  }
144  puts( "*** END OF TEST 10 ***" );
145  rtems_test_exit( 0 );
146}
Note: See TracBrowser for help on using the repository browser.