source: rtems/testsuites/sptests/sp04/init.c

Last change on this file was 72510115, checked in by Joel Sherrill <joel@…>, on 03/31/22 at 21:31:58

testsuites/sptests/sp0*: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*  Init
4 *
5 *  This routine is the initialization task for this test program.
6 *  It is a user initialization task and has the responsibility for creating
7 *  and starting the tasks that make up the test.  If the time of day
8 *  clock is required for the test, it should also be set to a known
9 *  value by this function.
10 *
11 *  Input parameters:
12 *    argument - task argument
13 *
14 *  Output parameters:  NONE
15 *
16 *  COPYRIGHT (c) 1989-1999.
17 *  On-Line Applications Research Corporation (OAR).
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 * 1. Redistributions of source code must retain the above copyright
23 *    notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright
25 *    notice, this list of conditions and the following disclaimer in the
26 *    documentation and/or other materials provided with the distribution.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifdef HAVE_CONFIG_H
42#include "config.h"
43#endif
44
45#define CONFIGURE_INIT
46#include "system.h"
47
48const char rtems_test_name[] = "SP 4";
49
50rtems_extensions_table Extensions = {
51  NULL,                      /* task create user extension */
52  NULL,                      /* task start user extension */
53  NULL,                      /* task restart user extension */
54  NULL,                      /* task delete user extension */
55  Task_switch,               /* task switch user extension */
56  NULL,                      /* task begin user extension */
57  NULL,                      /* task exitted user extension */
58  NULL                       /* fatal error user extension */
59};
60
61rtems_task Init(
62  rtems_task_argument argument
63)
64{
65  rtems_status_code status;
66  rtems_time_of_day time;
67
68  TEST_BEGIN();
69  build_time( &time, 12, 31, 1988, 9, 15, 0, 0 );
70
71  status = rtems_clock_set( &time );
72  directive_failed( status, "rtems_clock_set" );
73
74  Extension_name[ 1 ] =  rtems_build_name( 'E', 'X', 'T', ' ' );
75
76  status = rtems_extension_create(
77    Extension_name[ 1 ],
78    &Extensions,
79    &Extension_id[ 1 ]
80  );
81  directive_failed( status, "rtems_extension_create" );
82
83  Task_name[ 1 ] =  rtems_build_name( 'T', 'A', '1', ' ' );
84  Task_name[ 2 ] =  rtems_build_name( 'T', 'A', '2', ' ' );
85  Task_name[ 3 ] =  rtems_build_name( 'T', 'A', '3', ' ' );
86
87  Run_count[ 1 ] = 0;
88  Run_count[ 2 ] = 0;
89  Run_count[ 3 ] = 0;
90
91  status = rtems_task_create(
92     Task_name[ 1 ],
93     1,
94     RTEMS_MINIMUM_STACK_SIZE * 2,
95     RTEMS_PREEMPT|RTEMS_TIMESLICE,
96     RTEMS_DEFAULT_ATTRIBUTES,
97     &Task_id[ 1 ]
98  );
99  directive_failed( status, "rtems_task_create of TA1" );
100
101  status = rtems_task_create(
102     Task_name[ 2 ],
103     1,
104     RTEMS_MINIMUM_STACK_SIZE * 2,
105     RTEMS_PREEMPT|RTEMS_TIMESLICE,
106     RTEMS_GLOBAL,
107     &Task_id[ 2 ]
108  );
109  directive_failed( status, "rtems_task_create of TA2" );
110
111  status = rtems_task_create(
112     Task_name[ 3 ],
113     1,
114     RTEMS_MINIMUM_STACK_SIZE * 2,
115     RTEMS_PREEMPT|RTEMS_TIMESLICE,
116     RTEMS_DEFAULT_ATTRIBUTES,
117     &Task_id[ 3 ]
118  );
119  directive_failed( status, "rtems_task_create of TA3" );
120
121  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
122  directive_failed( status, "rtems_task_start of TA1" );
123
124  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
125  directive_failed( status, "rtems_task_start of TA2" );
126
127  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
128  directive_failed( status, "rtems_task_start of TA3" );
129
130  rtems_task_exit();
131}
Note: See TracBrowser for help on using the repository browser.