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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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