source: rtems/testsuites/sptests/sp76/init.c @ 9b6362da

Last change on this file since 9b6362da was 9b6362da, checked in by Sebastian Huber <sebastian.huber@…>, on 11/18/21 at 11:13:53

rtems: Use RTEMS_WHO_AM_I for rtems_task_ident()

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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[] = "SP 76";
17
18static rtems_task High_task(
19  rtems_task_argument index
20)
21{
22  rtems_status_code  status;
23  rtems_name         name;
24
25  status = rtems_object_get_classic_name( rtems_task_self(), &name );
26  directive_failed( status, "rtems_object_get_classic_name" );
27
28  put_name( name, FALSE );
29  puts( " - Successfully yielded it to higher priority task" );
30
31  TEST_END();
32  rtems_test_exit( 0 );
33}
34
35static rtems_task Equal_task(
36  rtems_task_argument index
37)
38{
39  rtems_test_assert( 0 );
40}
41
42static rtems_task Init(
43  rtems_task_argument argument
44)
45{
46  rtems_status_code     status;
47  rtems_id              id;
48  rtems_task_priority   old;
49
50  TEST_BEGIN();
51
52  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &id );
53  directive_failed( status, "task ident" );
54
55  /* to make sure it is equal to TA2 */
56  puts( "Set Init task priority = 2" );
57  status = rtems_task_set_priority( id, 2, &old );
58  directive_failed( status, "task priority" );
59
60  puts( "Create TA1 at higher priority task" );
61  status = rtems_task_create(
62    rtems_build_name( 'T', 'A', '1', ' ' ),
63    1,
64    RTEMS_MINIMUM_STACK_SIZE,
65    RTEMS_DEFAULT_MODES,
66    RTEMS_DEFAULT_ATTRIBUTES,
67    &id
68  );
69  directive_failed( status, "create 1" );
70
71  status = rtems_task_start( id, High_task, 1 );
72  directive_failed( status, "start 1" );
73
74  puts( "Create TA2 at equal priority task" );
75  status = rtems_task_create(
76    rtems_build_name( 'T', 'A', '2', ' ' ),
77    2,
78    RTEMS_MINIMUM_STACK_SIZE,
79    RTEMS_DEFAULT_MODES,
80    RTEMS_DEFAULT_ATTRIBUTES,
81    &id
82  );
83  directive_failed( status, "create 2" );
84
85  status = rtems_task_start( id, Equal_task, 1 );
86  directive_failed( status, "start 2" );
87
88  puts( "Yield to TA1" );
89  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
90  directive_failed( status, "yield" );
91
92  puts( "*** should now get here ***" );
93}
94
95/* configuration information */
96#include <bsp.h> /* for device driver prototypes */
97
98#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
99#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
100
101#define CONFIGURE_MAXIMUM_TASKS           3
102#define CONFIGURE_INIT_TASK_PRIORITY      2
103
104#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
105
106#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
107
108#define CONFIGURE_INIT
109#include <rtems/confdefs.h>
110/* end of file */
Note: See TracBrowser for help on using the repository browser.