source: rtems/testsuites/tmtests/tm06/task1.c @ 51b3cbca

5
Last change on this file since 51b3cbca 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.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
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#define CONFIGURE_INIT
15#include "system.h"
16
17const char rtems_test_name[] = "TIME TEST 6";
18
19rtems_id Task_id[ OPERATION_COUNT + 1 ];
20
21uint32_t   Task_restarted;
22
23rtems_task null_task(
24  rtems_task_argument argument
25);
26
27rtems_task Task_1(
28  rtems_task_argument argument
29);
30
31void test_init( void );
32
33rtems_task Init(
34  rtems_task_argument argument
35)
36{
37  rtems_status_code status;
38
39  Print_Warning();
40
41  TEST_BEGIN();
42
43  test_init();
44
45  rtems_task_exit();
46}
47
48void test_init( void )
49{
50  rtems_status_code status;
51  rtems_id          id;
52
53  Task_restarted = OPERATION_COUNT;
54
55  status = rtems_task_create(
56    rtems_build_name( 'T', 'I', 'M', 'E' ),
57    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
58    RTEMS_MINIMUM_STACK_SIZE,
59    RTEMS_DEFAULT_MODES,
60    RTEMS_DEFAULT_ATTRIBUTES,
61    &id
62  );
63  directive_failed( status, "rtems_task_create" );
64
65  status = rtems_task_start( id, Task_1, 0 );
66  directive_failed( status, "rtems_task_start" );
67}
68
69rtems_task Task_1(
70  rtems_task_argument argument
71)
72{
73  rtems_status_code status;
74  uint32_t    index;
75
76  if ( Task_restarted == OPERATION_COUNT )
77     benchmark_timer_initialize();
78
79  Task_restarted--;
80
81  if ( Task_restarted != 0 )
82    (void) rtems_task_restart( RTEMS_SELF, 0 );
83
84  end_time = benchmark_timer_read();
85
86  benchmark_timer_initialize();
87    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
88      (void) benchmark_timer_empty_function();
89  overhead = benchmark_timer_read();
90
91  put_time(
92    "rtems_task_restart: calling task",
93    end_time,
94    OPERATION_COUNT,
95    overhead,
96    0
97  );
98
99  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
100    status = rtems_task_create(
101      rtems_build_name( 'T', 'I', 'M', 'E' ),
102      RTEMS_MAXIMUM_PRIORITY - 1u,
103      RTEMS_MINIMUM_STACK_SIZE,
104      RTEMS_DEFAULT_MODES,
105      RTEMS_DEFAULT_ATTRIBUTES,
106      &Task_id[ index ]
107    );
108    directive_failed( status, "rtems_task_create loop" );
109
110    status = rtems_task_start( Task_id[ index ], null_task, 0 );
111    directive_failed( status, "rtems_task_start loop" );
112  }
113
114  benchmark_timer_initialize();
115    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
116      (void) rtems_task_suspend( Task_id[ index ] );
117  end_time = benchmark_timer_read();
118
119  put_time(
120    "rtems_task_suspend: returns to caller",
121    end_time,
122    OPERATION_COUNT,
123    0,
124    0
125  );
126
127  benchmark_timer_initialize();
128    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
129      (void) rtems_task_resume( Task_id[ index ] );
130  end_time = benchmark_timer_read();
131
132  put_time(
133    "rtems_task_resume: task readied returns to caller",
134    end_time,
135    OPERATION_COUNT,
136    0,
137    0
138  );
139
140  benchmark_timer_initialize();
141    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
142      (void) rtems_task_delete( Task_id[ index ] );
143  end_time = benchmark_timer_read();
144
145  put_time(
146    "rtems_task_delete: ready task",
147    end_time,
148    OPERATION_COUNT,
149    0,
150    0
151  );
152
153  TEST_END();
154  rtems_test_exit( 0 );
155}
156
157rtems_task null_task(
158  rtems_task_argument argument
159)
160{
161  while ( FOREVER )
162    ;
163}
Note: See TracBrowser for help on using the repository browser.