OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [tmtests/] [tm16/] [task1.c] - Blame information for rev 507

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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.OARcorp.com/rtems/license.html.
9
 *
10
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:43 chris Exp $
11
 */
12
 
13
#define TEST_INIT
14
#include "system.h"
15
 
16
rtems_unsigned32 Task_count;
17
 
18
rtems_task test_init(
19
  rtems_task_argument argument
20
);
21
 
22
rtems_task Middle_tasks(
23
  rtems_task_argument argument
24
);
25
 
26
rtems_task High_task(
27
  rtems_task_argument argument
28
);
29
 
30
rtems_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
 
58
rtems_task test_init(
59
  rtems_task_argument argument
60
)
61
{
62
  rtems_task_priority priority;
63
  rtems_status_code   status;
64
  rtems_unsigned32    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
 
101
rtems_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
 
122
rtems_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
  exit( 0 );
147
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.