source: rtems/testsuites/mptests/mp10/init.c @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 28, 1995 at 3:30:29 PM

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • 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#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      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 * 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      1024,
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      1024,
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      1024,
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( 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  exit( 0 );
146}
Note: See TracBrowser for help on using the repository browser.