source: rtems/testsuites/tmtests/tm16/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.3 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  rtems_task_exit();
60}
61
62rtems_task test_init(
63  rtems_task_argument argument
64)
65{
66  rtems_task_priority priority;
67  rtems_status_code   status;
68  int                 index;
69  rtems_task_entry    task_entry;
70
71/*  As each task is started, it preempts this task and
72 *  performs a blocking rtems_event_receive.  Upon completion of
73 *  this loop all created tasks are blocked.
74 */
75
76  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
77  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
78    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
79
80  for( index = 0 ; index < operation_count ; index++ ) {
81    status = rtems_task_create(
82      rtems_build_name( 'M', 'I', 'D', ' ' ),
83      priority,
84      RTEMS_MINIMUM_STACK_SIZE,
85      RTEMS_DEFAULT_MODES,
86      RTEMS_DEFAULT_ATTRIBUTES,
87      &Task_id[ index ]
88    );
89    directive_failed( status, "rtems_task_create LOOP" );
90
91    if (  index == operation_count-1 ) task_entry = High_task;
92    else                               task_entry = Middle_tasks;
93
94    status = rtems_task_start( Task_id[ index ], task_entry, 0 );
95    directive_failed( status, "rtems_task_start LOOP" );
96
97    priority--;
98  }
99
100  Task_count = 0;
101
102  benchmark_timer_initialize();
103    (void) rtems_event_send( Task_id[ Task_count ], RTEMS_EVENT_16 );
104  /* preempts task */
105}
106
107rtems_task Middle_tasks(
108  rtems_task_argument argument
109)
110{
111  rtems_event_set event_out;
112
113  (void) rtems_event_receive(              /* task blocks */
114           RTEMS_EVENT_16,
115           RTEMS_DEFAULT_OPTIONS,
116           RTEMS_NO_TIMEOUT,
117           &event_out
118         );
119
120  Task_count++;
121
122  (void) rtems_event_send(               /* preempts task */
123    Task_id[ Task_count ],
124    RTEMS_EVENT_16
125  );
126}
127
128rtems_task High_task(
129  rtems_task_argument argument
130)
131{
132  rtems_event_set event_out;
133
134  (void) rtems_event_receive(                /* task blocks */
135            RTEMS_EVENT_16,
136            RTEMS_DEFAULT_OPTIONS,
137            RTEMS_NO_TIMEOUT,
138            &event_out
139          );
140
141  end_time = benchmark_timer_read();
142
143  put_time(
144    "rtems_event_send: task readied preempts caller",
145    end_time,
146    operation_count - 1u,
147    0u,
148    0
149  );
150
151  TEST_END();
152  rtems_test_exit( 0 );
153}
Note: See TracBrowser for help on using the repository browser.