source: rtems/testsuites/tmtests/tm07/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: 2.6 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 Task_id[ OPERATION_COUNT+1 ], task_index;
18
19rtems_task High_task(
20  rtems_task_argument argument
21);
22
23rtems_task Middle_tasks(
24  rtems_task_argument argument
25);
26
27rtems_task Low_task(
28  rtems_task_argument argument
29);
30
31void test_init(void);
32
33int operation_count = OPERATION_COUNT;
34
35rtems_task Init(
36  rtems_task_argument argument
37)
38{
39  rtems_status_code status;
40
41  Print_Warning();
42
43  puts( "\n\n*** TIME TEST 7 ***" );
44
45  test_init();
46
47  status = rtems_task_delete( RTEMS_SELF );
48  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
49}
50
51void test_init(void)
52{
53  rtems_status_code   status;
54  rtems_task_priority priority;
55  rtems_task_entry    task_entry;
56  int                 index;
57
58  priority = RTEMS_MAXIMUM_PRIORITY - 1u;
59
60  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
61    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
62
63  for( index=0 ; index <= operation_count ; index++ ) {
64    status = rtems_task_create(
65      rtems_build_name( 'T', 'I', 'M', 'E' ),
66      priority,
67      RTEMS_MINIMUM_STACK_SIZE,
68      RTEMS_DEFAULT_MODES,
69      RTEMS_DEFAULT_ATTRIBUTES,
70      &Task_id[index]
71    );
72    directive_failed( status, "rtems_task_create" );
73    priority--;
74
75    if      ( index == 0 )               task_entry = Low_task;
76    else if ( index == operation_count ) task_entry = High_task;
77    else                                 task_entry = Middle_tasks;
78
79    status = rtems_task_start( Task_id[index], task_entry, 0 );
80    directive_failed( status, "rtems_task_start" );
81  }
82}
83
84rtems_task High_task(
85  rtems_task_argument argument
86)
87{
88  if ( argument != 0 ) {
89    end_time = benchmark_timer_read();
90
91    put_time(
92      "rtems_task_restart: suspended task preempts caller",
93      end_time,
94      operation_count,
95      0,
96      CALLING_OVERHEAD_TASK_RESTART
97    );
98  } else
99    (void) rtems_task_suspend( RTEMS_SELF );
100
101  puts( "*** END OF TEST 7 ***" );
102  rtems_test_exit( 0 );
103}
104
105rtems_task Middle_tasks(
106  rtems_task_argument argument
107)
108{
109  task_index++;
110
111  if ( argument != 0 )
112    (void) rtems_task_restart( Task_id[ task_index ], 0xffffffff );
113  else
114    (void) rtems_task_suspend( RTEMS_SELF );
115}
116
117rtems_task Low_task(
118  rtems_task_argument argument
119)
120{
121  task_index = 1;
122
123  benchmark_timer_initialize();
124  (void) rtems_task_restart( Task_id[ task_index ], 0xffffffff );
125}
Note: See TracBrowser for help on using the repository browser.