source: rtems/testsuites/tmtests/tm13/task1.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 3.1 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#include "system.h"
15#undef EXTERN
16#define EXTERN
17#include "conftbl.h"
18#include "gvar.h"
19
20rtems_id Queue_id;
21
22long Buffer[4];
23
24rtems_task test_init(
25  rtems_task_argument argument
26);
27
28rtems_task Middle_tasks(
29  rtems_task_argument argument
30);
31
32rtems_task High_task(
33  rtems_task_argument argument
34);
35
36void Init(
37  rtems_task_argument argument
38)
39{
40  rtems_status_code status;
41  rtems_id id;
42
43  puts( "\n\n*** TIME TEST 13 ***" );
44
45  status = rtems_task_create(
46    1,
47    251,
48    1024,
49    RTEMS_DEFAULT_MODES,
50    RTEMS_DEFAULT_ATTRIBUTES,
51    &id
52  );
53  directive_failed( status, "rtems_task_create" );
54
55  status = rtems_task_start( id, test_init, 0 );
56  directive_failed( status, "rtems_task_start" );
57
58  status = rtems_task_delete( RTEMS_SELF );
59  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
60}
61
62rtems_task test_init(
63  rtems_task_argument argument
64)
65{
66  rtems_unsigned32    index;
67  rtems_task_entry    task_entry;
68  rtems_task_priority priority;
69  rtems_id            task_id;
70  rtems_status_code   status;
71
72/*  As each task is started, it preempts this task and
73 *  performs a blocking rtems_message_queue_receive.  Upon completion of
74 *  this loop all created tasks are blocked.
75 */
76
77  status = rtems_message_queue_create(
78    rtems_build_name( 'M', 'Q', '1', ' '  ),
79    OPERATION_COUNT,
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      1024,
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 );
109}
110
111rtems_task Middle_tasks(
112  rtems_task_argument argument
113)
114{
115  (void) rtems_message_queue_receive(
116           Queue_id,
117           (long (*)[4]) Buffer,
118           RTEMS_DEFAULT_OPTIONS,
119           RTEMS_NO_TIMEOUT
120         );
121
122  (void) rtems_message_queue_urgent( Queue_id, (long (*)[4]) Buffer );
123}
124
125rtems_task High_task(
126  rtems_task_argument argument
127)
128{
129  (void) rtems_message_queue_receive(
130           Queue_id,
131           (long (*)[4]) Buffer,
132           RTEMS_DEFAULT_OPTIONS,
133           RTEMS_NO_TIMEOUT
134         );
135
136  end_time = Read_timer();
137
138  put_time(
139    "rtems_message_queue_urgent (preemptive)",
140    end_time,
141    OPERATION_COUNT,
142    0,
143    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
144  );
145
146  exit( 0 );
147}
Note: See TracBrowser for help on using the repository browser.