source: rtems/testsuites/sptests/spsimplesched01/init.c @ 99de42c

5
Last change on this file since 99de42c was 51b3cbca, checked in by Sebastian Huber <sebastian.huber@…>, on 10/04/18 at 13:23:25

tests: Use rtems_task_exit()

Update #3533.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  COPYRIGHT (c) 2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15
16const char rtems_test_name[] = "SPSIMPLESCHED 1";
17
18/* forward declarations to avoid warnings */
19rtems_task Init(rtems_task_argument argument);
20rtems_task Test_task(rtems_task_argument unused);
21
22/*
23 *  Keep the names and IDs in global variables so another task can use them.
24 */
25rtems_id   Task_id[ 4 ];         /* array of task ids */
26rtems_name Task_name[ 4 ];       /* array of task names */
27
28rtems_task Test_task(
29  rtems_task_argument unused
30)
31{
32  rtems_id           tid;
33  rtems_time_of_day  time;
34  uint32_t           task_index;
35  rtems_status_code  status;
36
37  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
38  directive_failed( status, "task ident" );
39
40  task_index = task_number( tid );
41  for ( ; ; ) {
42    status = rtems_clock_get_tod( &time );
43    directive_failed( status, "clock get tod" );
44    if ( time.second >= 35 ) {
45      TEST_END();
46      rtems_test_exit( 0 );
47    }
48    put_name( Task_name[ task_index ], FALSE );
49    print_time( " - rtems_clock_get_tod - ", &time, "\n" );
50    status = rtems_task_wake_after(
51      task_index * 5 * rtems_clock_get_ticks_per_second()
52    );
53    directive_failed( status, "wake after" );
54  }
55}
56
57rtems_task Init(
58  rtems_task_argument argument
59)
60{
61  rtems_status_code   status;
62  rtems_time_of_day   time;
63  rtems_task_priority old;
64
65  TEST_BEGIN();
66
67  time.year   = 1988;
68  time.month  = 12;
69  time.day    = 31;
70  time.hour   = 9;
71  time.minute = 0;
72  time.second = 0;
73  time.ticks  = 0;
74
75  status = rtems_clock_set( &time );
76
77  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
78  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
79  Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
80
81  status = rtems_task_create(
82    Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
83    RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ]
84  );
85  directive_failed( status, "create 1" );
86
87  status = rtems_task_create(
88    Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
89    RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ]
90  );
91  directive_failed( status, "create 2" );
92
93  status = rtems_task_create(
94    Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
95    RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ]
96  );
97  directive_failed( status, "create 3" );
98
99  status = rtems_task_start( Task_id[ 1 ], Test_task, 1 );
100  directive_failed( status, "start 1" );
101  rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
102
103  status = rtems_task_start( Task_id[ 2 ], Test_task, 2 );
104  directive_failed( status, "start 2" );
105  rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
106
107  status = rtems_task_start( Task_id[ 3 ], Test_task, 3 );
108  directive_failed( status, "start 3" );
109
110  status = rtems_task_set_priority( Task_id[1], 2, &old );
111  directive_failed( status, "set priority 1" );
112  status = rtems_task_set_priority( Task_id[2], 2, &old );
113  directive_failed( status, "set priority 2" );
114  status = rtems_task_set_priority( Task_id[3], 2, &old );
115  directive_failed( status, "set priority 3" );
116
117  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
118  directive_failed( status, "yield" );
119
120  rtems_task_exit();
121}
122
123/* configuration information */
124#include <bsp.h> /* for device driver prototypes */
125
126#define CONFIGURE_SCHEDULER_SIMPLE
127#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
128#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
129
130#define CONFIGURE_MAXIMUM_TASKS             4
131
132#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
133
134#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
135
136#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
137
138#define CONFIGURE_INIT
139#include <rtems/confdefs.h>
140/* end of file */
Note: See TracBrowser for help on using the repository browser.