source: rtems/testsuites/tmtests/tm02/task1.c @ 2ead50a

4.115
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on 03/21/14 at 15:48:01

tmtests: convert to test.h

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