source: rtems/testsuites/tmtests/tm13/task1.c @ 3652ad35

4.104.114.84.95
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 19, 1995 at 2:53:29 PM

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
4 *  On-Line Applications Research Corporation (OAR).
5 *  All rights assigned to U.S. Government, 1994.
6 *
7 *  This material may be reproduced by or for the U.S. Government pursuant
8 *  to the copyright license under the clause at DFARS 252.227-7013.  This
9 *  notice must appear in all copies of this file and its derivatives.
10 *
11 *  $Id$
12 */
13
14#define TEST_INIT
15#include "system.h"
16
17rtems_id Queue_id;
18
19long Buffer[4];
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
33void Init(
34  rtems_task_argument argument
35)
36{
37  rtems_status_code status;
38  rtems_id id;
39
40  Print_Warning();
41
42  puts( "\n\n*** TIME TEST 13 ***" );
43
44  status = rtems_task_create(
45    1,
46    251,
47    RTEMS_MINIMUM_STACK_SIZE,
48    RTEMS_DEFAULT_MODES,
49    RTEMS_DEFAULT_ATTRIBUTES,
50    &id
51  );
52  directive_failed( status, "rtems_task_create" );
53
54  status = rtems_task_start( id, test_init, 0 );
55  directive_failed( status, "rtems_task_start" );
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_unsigned32    index;
66  rtems_task_entry    task_entry;
67  rtems_task_priority priority;
68  rtems_id            task_id;
69  rtems_status_code   status;
70
71/*  As each task is started, it preempts this task and
72 *  performs a blocking rtems_message_queue_receive.  Upon completion of
73 *  this loop all created tasks are blocked.
74 */
75
76  status = rtems_message_queue_create(
77    rtems_build_name( 'M', 'Q', '1', ' '  ),
78    OPERATION_COUNT,
79    16,
80    RTEMS_DEFAULT_ATTRIBUTES,
81    &Queue_id
82  );
83  directive_failed( status, "rtems_message_queue_create" );
84
85  priority = 250;
86
87  for( index = 0; index < OPERATION_COUNT ; index++ ) {
88    status = rtems_task_create(
89      rtems_build_name( 'T', 'I', 'M', 'E'  ),
90      priority,
91      RTEMS_MINIMUM_STACK_SIZE,
92      RTEMS_DEFAULT_MODES,
93      RTEMS_DEFAULT_ATTRIBUTES,
94      &task_id
95    );
96    directive_failed( status, "rtems_task_create LOOP" );
97
98    priority--;
99
100    if ( index==OPERATION_COUNT-1 ) task_entry = High_task;
101    else                            task_entry = Middle_tasks;
102
103    status = rtems_task_start( task_id, task_entry, 0 );
104    directive_failed( status, "rtems_task_start LOOP" );
105  }
106
107  Timer_initialize();
108    (void) rtems_message_queue_urgent( Queue_id, (long (*)[4]) Buffer, 16 );
109}
110
111rtems_task Middle_tasks(
112  rtems_task_argument argument
113)
114{
115  rtems_unsigned32 size;
116
117  (void) rtems_message_queue_receive(
118           Queue_id,
119           (long (*)[4]) Buffer,
120           &size,
121           RTEMS_DEFAULT_OPTIONS,
122           RTEMS_NO_TIMEOUT
123         );
124
125  (void) rtems_message_queue_urgent( Queue_id, (long (*)[4]) Buffer, size );
126}
127
128rtems_task High_task(
129  rtems_task_argument argument
130)
131{
132  rtems_unsigned32 size;
133
134  (void) rtems_message_queue_receive(
135           Queue_id,
136           (long (*)[4]) Buffer,
137           &size,
138           RTEMS_DEFAULT_OPTIONS,
139           RTEMS_NO_TIMEOUT
140         );
141
142  end_time = Read_timer();
143
144  put_time(
145    "rtems_message_queue_urgent (preemptive)",
146    end_time,
147    OPERATION_COUNT,
148    0,
149    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
150  );
151
152  puts( "*** END OF TEST 13 ***" );
153  exit( 0 );
154}
Note: See TracBrowser for help on using the repository browser.