source: rtems/testsuites/tmtests/tm02/task1.c @ 556fb911

4.104.114.84.95
Last change on this file since 556fb911 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 High_id;
21rtems_id Low_id;
22rtems_id Semaphore_id;
23
24rtems_task High_task(
25  rtems_task_argument argument
26);
27
28rtems_task Middle_tasks(
29  rtems_task_argument argument
30);
31
32rtems_task Low_task(
33  rtems_task_argument argument
34);
35
36
37void test_init();
38
39rtems_task Init(
40  rtems_task_argument argument
41)
42{
43  rtems_status_code status;
44
45  puts( "\n\n*** TIME TEST 2 ***" );
46
47  test_init();
48
49  status = rtems_task_delete( RTEMS_SELF );
50  directive_failed( status, "rtems_task_delete" );
51}
52
53void test_init()
54{
55  rtems_status_code   status;
56  rtems_unsigned32    index;
57  rtems_task_priority priority;
58
59  priority = 5;
60
61  status = rtems_task_create(
62    rtems_build_name( 'H', 'I', 'G', 'H' ),
63    priority,
64    1024,
65    RTEMS_DEFAULT_MODES,
66    RTEMS_DEFAULT_ATTRIBUTES,
67    &High_id
68  );
69  directive_failed( status, "rtems_task_create of high task" );
70
71  priority++;
72
73  status = rtems_task_start( High_id, High_task, 0 );
74  directive_failed( status, "rtems_task_start of high task" );
75
76  for ( index=2 ; index <= OPERATION_COUNT ; index++ ) {
77    status = rtems_task_create(
78      rtems_build_name( 'M', 'I', 'D', ' ' ),
79      priority,
80      1024,
81      RTEMS_DEFAULT_MODES,
82      RTEMS_DEFAULT_ATTRIBUTES,
83      &Low_id
84    );
85    directive_failed( status, "rtems_task_create middle" );
86
87    priority++;
88
89    status = rtems_task_start( Low_id, Middle_tasks, 0 );
90    directive_failed( status, "rtems_task_start middle" );
91  }
92
93  status = rtems_task_create(
94    rtems_build_name( 'L', 'O', 'W', ' ' ),
95    priority,
96    2048,
97    RTEMS_DEFAULT_MODES,
98    RTEMS_DEFAULT_ATTRIBUTES,
99    &Low_id
100  );
101  directive_failed( status, "rtems_task_create low" );
102
103  status = rtems_task_start( Low_id, Low_task, 0 );
104  directive_failed( status, "rtems_task_start low" );
105
106  status = rtems_semaphore_create(
107    rtems_build_name( 'S', 'M', '1', ' '),
108    0,
109    RTEMS_DEFAULT_ATTRIBUTES,
110    &Semaphore_id
111  );
112  directive_failed( status, "rtems_semaphore_create of SM1" );
113}
114
115rtems_task High_task(
116  rtems_task_argument argument
117)
118{
119  rtems_status_code status;
120
121  Timer_initialize();           /* start blocking rtems_semaphore_obtain time */
122  status = rtems_semaphore_obtain(
123    Semaphore_id,
124    RTEMS_DEFAULT_OPTIONS,
125    RTEMS_NO_TIMEOUT
126  );
127}
128
129rtems_task Middle_tasks(
130  rtems_task_argument argument
131)
132{
133  rtems_status_code status;
134
135  status = rtems_semaphore_obtain(
136    Semaphore_id,
137    RTEMS_DEFAULT_OPTIONS,
138    RTEMS_NO_TIMEOUT
139  );
140}
141
142rtems_task Low_task(
143  rtems_task_argument argument
144)
145{
146  end_time = Read_timer();
147
148  put_time(
149    "rtems_semaphore_obtain (blocking)",
150    end_time,
151    OPERATION_COUNT,
152    0,
153    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
154  );
155  exit( 0 );
156}
Note: See TracBrowser for help on using the repository browser.