source: rtems/testsuites/mptests/mp10/initimpl.h @ 0b520cb

5
Last change on this file since 0b520cb was 0b520cb, checked in by Sebastian Huber <sebastian.huber@…>, on 11/06/19 at 18:28:29

mptests: Avoid build system defined defines

Update #3818.

  • 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-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.org/license/LICENSE.
26 */
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#define CONFIGURE_INIT
33#include "system.h"
34
35rtems_task Init(
36  rtems_task_argument argument
37)
38{
39  rtems_status_code status;
40
41  printf(
42   "\n\n*** TEST 10 -- NODE %" PRIu32 " ***\n",
43   Multiprocessing_configuration.node
44  );
45
46  Task_name[ 1 ] =  rtems_build_name( 'T', 'A', '1', ' ' );
47  Task_name[ 2 ] =  rtems_build_name( 'T', 'A', '2', ' ' );
48  Task_name[ 3 ] =  rtems_build_name( 'S', 'A', '3', ' ' );
49
50  Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' );
51
52  Semaphore_name[ 1 ] = rtems_build_name( 'S', 'E', 'M', ' ' );
53
54  if ( Multiprocessing_configuration.node == 1 ) {
55    puts( "Creating Message Queue (Global)" );
56    status = rtems_message_queue_create(
57      Queue_name[ 1 ],
58      3,
59      16,
60      RTEMS_GLOBAL,
61      &Queue_id[ 1 ]
62    );
63    directive_failed( status, "rtems_message_queue_create" );
64
65    puts( "Creating Semaphore (Global)" );
66    status = rtems_semaphore_create(
67      Semaphore_name[ 1 ],
68      0,
69      RTEMS_GLOBAL | RTEMS_PRIORITY,
70      RTEMS_NO_PRIORITY,
71      &Semaphore_id[ 1 ]
72    );
73    directive_failed( status, "rtems_semaphore_create" );
74
75    status = rtems_task_wake_after( 10 * rtems_clock_get_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      RTEMS_MINIMUM_STACK_SIZE,
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      RTEMS_MINIMUM_STACK_SIZE,
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      RTEMS_MINIMUM_STACK_SIZE,
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( rtems_clock_get_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  rtems_test_exit( 0 );
144}
Note: See TracBrowser for help on using the repository browser.