source: rtems/testsuites/tmtests/tm02/task1.c @ c499856

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17rtems_id High_id;
18rtems_id Low_id;
19rtems_id Semaphore_id;
20
21rtems_task High_task(
22  rtems_task_argument argument
23);
24
25rtems_task Middle_tasks(
26  rtems_task_argument argument
27);
28
29rtems_task Low_task(
30  rtems_task_argument argument
31);
32
33int operation_count = OPERATION_COUNT;
34
35void test_init(void);
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  rtems_status_code status;
42
43  Print_Warning();
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(void)
54{
55  rtems_status_code   status;
56  int                 index;
57  rtems_task_priority priority;
58
59  priority = 2;
60
61  status = rtems_task_create(
62    rtems_build_name( 'H', 'I', 'G', 'H' ),
63    priority,
64    RTEMS_MINIMUM_STACK_SIZE,
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  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
77    operation_count = (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
78  for ( index=2 ; index < operation_count ; index++ ) {
79    status = rtems_task_create(
80      rtems_build_name( 'M', 'I', 'D', ' ' ),
81      priority,
82      RTEMS_MINIMUM_STACK_SIZE,
83      RTEMS_DEFAULT_MODES,
84      RTEMS_DEFAULT_ATTRIBUTES,
85      &Low_id
86    );
87    directive_failed( status, "rtems_task_create middle" );
88
89    priority++;
90
91    status = rtems_task_start( Low_id, Middle_tasks, 0 );
92    directive_failed( status, "rtems_task_start middle" );
93  }
94
95  status = rtems_task_create(
96    rtems_build_name( 'L', 'O', 'W', ' ' ),
97    priority,
98    RTEMS_MINIMUM_STACK_SIZE,
99    RTEMS_DEFAULT_MODES,
100    RTEMS_DEFAULT_ATTRIBUTES,
101    &Low_id
102  );
103  directive_failed( status, "rtems_task_create low" );
104
105  status = rtems_task_start( Low_id, Low_task, 0 );
106  directive_failed( status, "rtems_task_start low" );
107
108  status = rtems_semaphore_create(
109    rtems_build_name( 'S', 'M', '1', ' '),
110    0,
111    RTEMS_DEFAULT_ATTRIBUTES,
112    RTEMS_NO_PRIORITY,
113    &Semaphore_id
114  );
115  directive_failed( status, "rtems_semaphore_create of SM1" );
116}
117
118rtems_task High_task(
119  rtems_task_argument argument
120)
121{
122  /* start blocking rtems_semaphore_obtain time */
123  benchmark_timer_initialize();
124
125  (void) rtems_semaphore_obtain(
126    Semaphore_id,
127    RTEMS_DEFAULT_OPTIONS,
128    RTEMS_NO_TIMEOUT
129  );
130}
131
132rtems_task Middle_tasks(
133  rtems_task_argument argument
134)
135{
136  (void) 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 = benchmark_timer_read();
148
149  put_time(
150    "rtems_semaphore_obtain: not available caller blocks",
151    end_time,
152    operation_count - 1,
153    0,
154    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
155  );
156
157  puts( "*** END OF TEST 2 ***" );
158  rtems_test_exit( 0 );
159}
Note: See TracBrowser for help on using the repository browser.