source: rtems/c/src/tests/tmtests/tm02/task1.c @ 5072b07

4.104.114.84.95
Last change on this file since 5072b07 was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on 08/28/95 at 15:30:29

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • 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    RTEMS_NO_PRIORITY,
111    &Semaphore_id
112  );
113  directive_failed( status, "rtems_semaphore_create of SM1" );
114}
115
116rtems_task High_task(
117  rtems_task_argument argument
118)
119{
120  rtems_status_code status;
121
122  Timer_initialize();           /* start blocking rtems_semaphore_obtain time */
123  status = rtems_semaphore_obtain(
124    Semaphore_id,
125    RTEMS_DEFAULT_OPTIONS,
126    RTEMS_NO_TIMEOUT
127  );
128}
129
130rtems_task Middle_tasks(
131  rtems_task_argument argument
132)
133{
134  rtems_status_code status;
135
136  status = rtems_semaphore_obtain(
137    Semaphore_id,
138    RTEMS_DEFAULT_OPTIONS,
139    RTEMS_NO_TIMEOUT
140  );
141}
142
143rtems_task Low_task(
144  rtems_task_argument argument
145)
146{
147  end_time = Read_timer();
148
149  put_time(
150    "rtems_semaphore_obtain (blocking)",
151    end_time,
152    OPERATION_COUNT,
153    0,
154    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
155  );
156  exit( 0 );
157}
Note: See TracBrowser for help on using the repository browser.