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