source: rtems/testsuites/tmtests/tm16/task1.c @ af43554

5
Last change on this file since af43554 was af43554, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:11

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 3.4 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 16";
18
19uint32_t   Task_count;
20
21rtems_task test_init(
22  rtems_task_argument argument
23);
24
25rtems_task Middle_tasks(
26  rtems_task_argument argument
27);
28
29rtems_task High_task(
30  rtems_task_argument argument
31);
32
33int operation_count = OPERATION_COUNT;
34
35rtems_task Init(
36  rtems_task_argument argument
37)
38{
39  rtems_id          id;
40  rtems_status_code status;
41
42  Print_Warning();
43
44  TEST_BEGIN();
45
46  status = rtems_task_create(
47    rtems_build_name( 'T', 'E', 'S', 'T' ),
48    RTEMS_MAXIMUM_PRIORITY - 1u,
49    RTEMS_MINIMUM_STACK_SIZE,
50    RTEMS_DEFAULT_MODES,
51    RTEMS_DEFAULT_ATTRIBUTES,
52    &id
53  );
54  directive_failed( status, "rtems_task_create of test_init" );
55
56  status = rtems_task_start( id, test_init, 0 );
57  directive_failed( status, "rtems_task_start of test_init" );
58
59  status = rtems_task_delete( RTEMS_SELF );
60  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
61}
62
63rtems_task test_init(
64  rtems_task_argument argument
65)
66{
67  rtems_task_priority priority;
68  rtems_status_code   status;
69  int                 index;
70  rtems_task_entry    task_entry;
71
72/*  As each task is started, it preempts this task and
73 *  performs a blocking rtems_event_receive.  Upon completion of
74 *  this loop all created tasks are blocked.
75 */
76
77  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
78  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
79    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
80
81  for( index = 0 ; index < operation_count ; index++ ) {
82    status = rtems_task_create(
83      rtems_build_name( 'M', 'I', 'D', ' ' ),
84      priority,
85      RTEMS_MINIMUM_STACK_SIZE,
86      RTEMS_DEFAULT_MODES,
87      RTEMS_DEFAULT_ATTRIBUTES,
88      &Task_id[ index ]
89    );
90    directive_failed( status, "rtems_task_create LOOP" );
91
92    if (  index == operation_count-1 ) task_entry = High_task;
93    else                               task_entry = Middle_tasks;
94
95    status = rtems_task_start( Task_id[ index ], task_entry, 0 );
96    directive_failed( status, "rtems_task_start LOOP" );
97
98    priority--;
99  }
100
101  Task_count = 0;
102
103  benchmark_timer_initialize();
104    (void) rtems_event_send( Task_id[ Task_count ], RTEMS_EVENT_16 );
105  /* preempts task */
106}
107
108rtems_task Middle_tasks(
109  rtems_task_argument argument
110)
111{
112  rtems_event_set event_out;
113
114  (void) rtems_event_receive(              /* task blocks */
115           RTEMS_EVENT_16,
116           RTEMS_DEFAULT_OPTIONS,
117           RTEMS_NO_TIMEOUT,
118           &event_out
119         );
120
121  Task_count++;
122
123  (void) rtems_event_send(               /* preempts task */
124    Task_id[ Task_count ],
125    RTEMS_EVENT_16
126  );
127}
128
129rtems_task High_task(
130  rtems_task_argument argument
131)
132{
133  rtems_event_set event_out;
134
135  (void) rtems_event_receive(                /* task blocks */
136            RTEMS_EVENT_16,
137            RTEMS_DEFAULT_OPTIONS,
138            RTEMS_NO_TIMEOUT,
139            &event_out
140          );
141
142  end_time = benchmark_timer_read();
143
144  put_time(
145    "rtems_event_send: task readied preempts caller",
146    end_time,
147    operation_count - 1u,
148    0u,
149    CALLING_OVERHEAD_EVENT_SEND
150  );
151
152  TEST_END();
153  rtems_test_exit( 0 );
154}
Note: See TracBrowser for help on using the repository browser.