source: rtems/testsuites/tmtests/tm03/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
16rtems_id Semaphore_id;
17rtems_task test_init(
18  rtems_task_argument argument
19);
20
21rtems_task Middle_tasks(
22  rtems_task_argument argument
23);
24
25rtems_task High_task(
26  rtems_task_argument argument
27);
28
29
30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  rtems_status_code status;
35  rtems_id          task_id;
36
37  Print_Warning();
38
39  puts( "\n\n*** TIME TEST 3 ***" );
40  status = rtems_task_create(
41    rtems_build_name( 'T', 'A', '1', ' ' ),
42    252,
43    RTEMS_MINIMUM_STACK_SIZE,
44    RTEMS_DEFAULT_MODES,
45    RTEMS_DEFAULT_ATTRIBUTES,
46    &task_id
47  );
48  directive_failed( status, "rtems_task_create of test_init" );
49
50  status = rtems_task_start( task_id, test_init, 0 );
51  directive_failed( status, "rtems_task_start of test_init" );
52
53  status = rtems_task_delete( RTEMS_SELF );
54  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
55}
56
57rtems_task test_init(
58  rtems_task_argument argument
59)
60{
61  rtems_status_code   status;
62  uint32_t      index;
63  rtems_id            task_id;
64  rtems_task_priority priority;
65
66  priority = 250;
67
68  status = rtems_semaphore_create(
69    rtems_build_name( 'S', 'M', '1', '\0'),
70    0,
71    RTEMS_DEFAULT_ATTRIBUTES,
72    RTEMS_NO_PRIORITY,
73    &Semaphore_id
74  );
75  directive_failed( status, "rtems_semaphore_create of SM1" );
76
77  for ( index = 2 ; index <= OPERATION_COUNT ; index ++ ) {
78    rtems_task_create(
79      rtems_build_name( 'M', 'I', 'D', ' ' ),
80      priority,
81      RTEMS_MINIMUM_STACK_SIZE,
82      RTEMS_DEFAULT_MODES,
83      RTEMS_DEFAULT_ATTRIBUTES,
84      &task_id
85    );
86    directive_failed( status, "rtems_task_create middle" );
87
88    priority--;
89
90    rtems_task_start( task_id, Middle_tasks, 0 );
91    directive_failed( status, "rtems_task_start middle" );
92  }
93
94  status = rtems_task_create(
95    rtems_build_name( 'H', 'I', 'G', 'H' ),
96    priority,
97    RTEMS_MINIMUM_STACK_SIZE,
98    RTEMS_DEFAULT_MODES,
99    RTEMS_DEFAULT_ATTRIBUTES,
100    &task_id
101  );
102  directive_failed( status, "rtems_task_create of high task" );
103
104  status = rtems_task_start( task_id, High_task, 0 );
105  directive_failed( status, "rtems_task_start of high task" );
106
107  Timer_initialize();                          /* start the timer */
108  status = rtems_semaphore_release( Semaphore_id );
109}
110
111rtems_task Middle_tasks(
112  rtems_task_argument argument
113)
114{
115  rtems_status_code status;
116
117  status = rtems_semaphore_obtain(
118    Semaphore_id,
119    RTEMS_DEFAULT_OPTIONS,
120    RTEMS_NO_TIMEOUT
121  );
122
123  status = rtems_semaphore_release( Semaphore_id );
124}
125
126rtems_task High_task(
127  rtems_task_argument argument
128)
129{
130  rtems_status_code status;
131
132  status = rtems_semaphore_obtain(
133    Semaphore_id,
134    RTEMS_DEFAULT_OPTIONS,
135    RTEMS_NO_TIMEOUT
136  );
137
138  end_time = Read_timer();
139
140  put_time(
141    "rtems_semaphore_release: task readied -- preempts caller",
142    end_time,
143    OPERATION_COUNT,
144    0,
145    CALLING_OVERHEAD_SEMAPHORE_RELEASE
146  );
147
148  puts( "*** END OF TEST 3 ***" );
149  rtems_test_exit( 0 );
150}
Note: See TracBrowser for help on using the repository browser.