source: rtems/testsuites/tmtests/tm16/task1.c @ 0720ff4

4.104.114.84.9
Last change on this file since 0720ff4 was 0720ff4, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 28, 2004 at 7:20:11 AM

2004-03-28 Ralf Corsepius <ralf_corsepius@…>

  • include/timesys.h, tm01/task1.c, tm02/task1.c, tm03/task1.c, tm04/task1.c, tm05/task1.c, tm06/task1.c, tm07/task1.c, tm08/task1.c, tm09/task1.c, tm10/task1.c, tm11/task1.c, tm12/task1.c, tm13/task1.c, tm14/task1.c, tm15/task1.c, tm16/task1.c, tm17/task1.c, tm18/task1.c, tm20/task1.c, tm21/task1.c, tm22/task1.c, tm23/task1.c, tm24/task1.c, tm25/task1.c, tm26/task1.c, tm27/task1.c, tm28/task1.c, tm29/task1.c, tmck/task1.c, tmoverhd/testtask.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989-1999.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id$
11 */
12
13#define TEST_INIT
14#include "system.h"
15
16uint32_t   Task_count;
17
18rtems_task test_init(
19  rtems_task_argument argument
20);
21
22rtems_task Middle_tasks(
23  rtems_task_argument argument
24);
25
26rtems_task High_task(
27  rtems_task_argument argument
28);
29
30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  rtems_id          id;
35  rtems_status_code status;
36
37  Print_Warning();
38
39  puts( "\n\n*** TIME TEST 16 ***" );
40
41  status = rtems_task_create(
42    rtems_build_name( 'T', 'E', 'S', 'T' ),
43    251,
44    RTEMS_MINIMUM_STACK_SIZE,
45    RTEMS_DEFAULT_MODES,
46    RTEMS_DEFAULT_ATTRIBUTES,
47    &id
48  );
49  directive_failed( status, "rtems_task_create of test_init" );
50
51  status = rtems_task_start( id, test_init, 0 );
52  directive_failed( status, "rtems_task_start of test_init" );
53
54  status = rtems_task_delete( RTEMS_SELF );
55  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
56}
57
58rtems_task test_init(
59  rtems_task_argument argument
60)
61{
62  rtems_task_priority priority;
63  rtems_status_code   status;
64  uint32_t      index;
65  rtems_task_entry    task_entry;
66
67/*  As each task is started, it preempts this task and
68 *  performs a blocking rtems_event_receive.  Upon completion of
69 *  this loop all created tasks are blocked.
70 */
71
72  priority = 250;
73
74  for( index = 0 ; index <= OPERATION_COUNT ; index++ ) {
75    status = rtems_task_create(
76      rtems_build_name( 'M', 'I', 'D', ' ' ),
77      priority,
78      RTEMS_MINIMUM_STACK_SIZE,
79      RTEMS_DEFAULT_MODES,
80      RTEMS_DEFAULT_ATTRIBUTES,
81      &Task_id[ index ]
82    );
83    directive_failed( status, "rtems_task_create LOOP" );
84
85    if (  index == OPERATION_COUNT ) task_entry = High_task;
86    else                             task_entry = Middle_tasks;
87
88    status = rtems_task_start( Task_id[ index ], task_entry, 0 );
89    directive_failed( status, "rtems_task_start LOOP" );
90
91    priority--;
92  }
93
94  Task_count = 0;
95
96  Timer_initialize();
97    (void) rtems_event_send( Task_id[ Task_count ], RTEMS_EVENT_16 );
98  /* preempts task */
99}
100
101rtems_task Middle_tasks(
102  rtems_task_argument argument
103)
104{
105  rtems_event_set event_out;
106
107  (void) rtems_event_receive(              /* task blocks */
108           RTEMS_EVENT_16,
109           RTEMS_DEFAULT_OPTIONS,
110           RTEMS_NO_TIMEOUT,
111           &event_out
112         );
113
114  Task_count++;
115
116  (void) rtems_event_send(               /* preempts task */
117    Task_id[ Task_count ],
118    RTEMS_EVENT_16
119  );
120}
121
122rtems_task High_task(
123  rtems_task_argument argument
124)
125{
126  rtems_event_set event_out;
127
128  (void) rtems_event_receive(                /* task blocks */
129            RTEMS_EVENT_16,
130            RTEMS_DEFAULT_OPTIONS,
131            RTEMS_NO_TIMEOUT,
132            &event_out
133          );
134
135  end_time = Read_timer();
136
137  put_time(
138    "rtems_event_send: task readied -- preempts caller",
139    end_time,
140    OPERATION_COUNT,
141    0,
142    CALLING_OVERHEAD_EVENT_SEND
143  );
144
145  puts( "*** END OF TEST 16 ***" );
146  rtems_test_exit( 0 );
147}
Note: See TracBrowser for help on using the repository browser.