source: rtems/testsuites/samples/ticker/init.c

Last change on this file was e71f0909, checked in by Joel Sherrill <joel@…>, on 04/07/22 at 16:13:34

testsuites/samples: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[e71f0909]1/* SPDX-License-Identifier: BSD-2-Clause */
2
[5f0cd34]3/*
4 *  COPYRIGHT (c) 1989-2012.
[ac7d5ef0]5 *  On-Line Applications Research Corporation (OAR).
6 *
[e71f0909]7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
[ac7d5ef0]27 */
28
[e313551]29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
[df49c60]33#define CONFIGURE_INIT
[ac7d5ef0]34#include "system.h"
[df49c60]35
[9391f6d]36const char rtems_test_name[] = "CLOCK TICK";
37
[df49c60]38/*
39 *  Keep the names and IDs in global variables so another task can use them.
40 */
41
42rtems_id   Task_id[ 4 ];         /* array of task ids */
43rtems_name Task_name[ 4 ];       /* array of task names */
[ac7d5ef0]44
45rtems_task Init(
46  rtems_task_argument argument
47)
48{
49  rtems_status_code status;
50  rtems_time_of_day time;
51
[9391f6d]52  TEST_BEGIN();
[ac7d5ef0]53
[df49c60]54  time.year   = 1988;
55  time.month  = 12;
56  time.day    = 31;
57  time.hour   = 9;
58  time.minute = 0;
59  time.second = 0;
60  time.ticks  = 0;
61
[ac7d5ef0]62  status = rtems_clock_set( &time );
[6eae5860]63  directive_failed( status, "clock set" );
[ac7d5ef0]64
65  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
66  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
67  Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
68
[3652ad35]69  status = rtems_task_create(
[5fe6b21a]70    Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
[3652ad35]71    RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ]
72  );
[7c1e6942]73  directive_failed( status, "create 1" );
74
[3652ad35]75  status = rtems_task_create(
[5fe6b21a]76    Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
[3652ad35]77    RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ]
78  );
[7c1e6942]79  directive_failed( status, "create 2" );
80
[3652ad35]81  status = rtems_task_create(
[5fe6b21a]82    Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
[3652ad35]83    RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ]
84  );
[7c1e6942]85  directive_failed( status, "create 3" );
[ac7d5ef0]86
87  status = rtems_task_start( Task_id[ 1 ], Test_task, 1 );
[7c1e6942]88  directive_failed( status, "start 1" );
89
[ac7d5ef0]90  status = rtems_task_start( Task_id[ 2 ], Test_task, 2 );
[7c1e6942]91  directive_failed( status, "start 2" );
92
[ac7d5ef0]93  status = rtems_task_start( Task_id[ 3 ], Test_task, 3 );
[7c1e6942]94  directive_failed( status, "start 3" );
[ac7d5ef0]95
[51b3cbca]96  rtems_task_exit();
[ac7d5ef0]97}
Note: See TracBrowser for help on using the repository browser.