OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [mptests/] [mp10/] [init.c] - Blame information for rev 173

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.