source: rtems/testsuites/tmtests/tm13/task1.c @ 2ead50a

4.11
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on Mar 21, 2014 at 3:48:01 PM

tmtests: convert to test.h

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