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

4.11
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on Mar 21, 2014 at 3:48:01 PM

tmtests: convert to test.h

  • Property mode set to 100644
File size: 2.7 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 5";
18
19rtems_id   Task_id[OPERATION_COUNT+1];
20uint32_t   Task_index;
21
22rtems_task High_task(
23  rtems_task_argument argument
24);
25
26rtems_task Middle_tasks(
27  rtems_task_argument argument
28);
29
30rtems_task Low_task(
31  rtems_task_argument argument
32);
33
34extern void test_init(void);
35
36int operation_count = OPERATION_COUNT;
37
38rtems_task Init(
39  rtems_task_argument argument
40)
41{
42  rtems_status_code status;
43
44  Print_Warning();
45
46  TEST_BEGIN();
47
48  test_init();
49
50  status = rtems_task_delete( RTEMS_SELF );
51  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
52}
53
54void test_init(void)
55{
56  rtems_status_code   status;
57  rtems_task_entry    task_entry;
58  rtems_task_priority priority;
59  uint32_t      index;
60
61  priority = RTEMS_MAXIMUM_PRIORITY - 1;
62
63  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
64    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
65
66  for( index = 0; index <= operation_count ; index++ ) {
67
68    status = rtems_task_create(
69      rtems_build_name( 'T', 'I', 'M', 'E' ),
70      priority,
71      RTEMS_MINIMUM_STACK_SIZE,
72      RTEMS_DEFAULT_MODES,
73      RTEMS_DEFAULT_ATTRIBUTES,
74      &Task_id[ index ]
75    );
76    directive_failed( status, "rtems_task_create loop" );
77
78    priority--;
79
80    if ( index==0 )                    task_entry = Low_task;
81    else if ( index==operation_count ) task_entry = High_task;
82    else                               task_entry = Middle_tasks;
83
84    status = rtems_task_start( Task_id[ index ], task_entry, 0 );
85    directive_failed( status, "rtems_task_start loop" );
86  }
87}
88
89rtems_task High_task(
90  rtems_task_argument argument
91)
92{
93  benchmark_timer_initialize();
94
95  (void) rtems_task_suspend( RTEMS_SELF );
96
97  end_time = benchmark_timer_read();
98
99  put_time(
100    "rtems_task_resume: task readied preempts caller",
101    end_time,
102    operation_count,
103    0,
104    CALLING_OVERHEAD_TASK_RESUME
105  );
106
107  TEST_END();
108  rtems_test_exit( 0 );
109}
110
111rtems_task Middle_tasks(
112  rtems_task_argument argument
113)
114{
115  (void) rtems_task_suspend( RTEMS_SELF );
116
117  Task_index++;
118  (void) rtems_task_resume( Task_id[ Task_index ] );
119}
120
121rtems_task Low_task(
122  rtems_task_argument argument
123)
124{
125
126  end_time = benchmark_timer_read();
127
128  put_time(
129    "rtems_task_suspend: calling task",
130    end_time,
131    operation_count,
132    0,
133    CALLING_OVERHEAD_TASK_SUSPEND
134  );
135
136  Task_index = 1;
137  benchmark_timer_initialize();
138  (void) rtems_task_resume( Task_id[ Task_index ] );
139}
Note: See TracBrowser for help on using the repository browser.