source: rtems/testsuites/tmtests/tm17/task1.c @ 4389287a

4.104.115
Last change on this file since 4389287a was 4389287a, checked in by Joel Sherrill <joel.sherrill@…>, on 12/14/08 at 18:38:45

2008-12-14 Joel Sherrill <joel.sherrill@…>

  • tm01/task1.c, tm02/task1.c, tm03/task1.c, tm04/task1.c, tm05/task1.c, tm06/task1.c, tm07/task1.c, tm08/task1.c, tm09/task1.c, tm10/task1.c, tm11/task1.c, tm12/task1.c, tm13/task1.c, tm14/task1.c, tm16/task1.c, tm17/task1.c, tm18/task1.c, tm19/task1.c, tm20/task1.c, tm21/task1.c, tm23/task1.c, tm24/task1.c, tm25/task1.c, tm26/task1.c, tm27/task1.c, tm28/task1.c, tm29/task1.c, tmoverhd/testtask.c: Run all tests successfully with maxixum number of priorities as 16 instead of 256. This was done by temporarily modifying the score priority.h maximum. This allowed testing of all API code to ensure that it worked properly with a reduced number of priorities. Most modifications were to switch from hard-coded maximum to using the API provided methods to determine maximum number of priority levels.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
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.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#define CONFIGURE_INIT
13#include "system.h"
14
15uint32_t   Task_count;
16rtems_task_priority Task_priority;
17
18rtems_task First_task(
19  rtems_task_argument argument
20);
21
22rtems_task Middle_tasks(
23  rtems_task_argument argument
24);
25
26rtems_task Last_task(
27  rtems_task_argument argument
28);
29
30int operation_count = OPERATION_COUNT;
31
32rtems_task Init(
33  rtems_task_argument argument
34)
35{
36  rtems_task_entry  task_entry;
37  uint32_t    index;
38  rtems_status_code status;
39
40  Print_Warning();
41
42  puts( "\n\n*** TIME TEST 17 ***" );
43
44  Task_priority = RTEMS_MAXIMUM_PRIORITY - 1;
45  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
46    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
47
48  for( index = 0; index < operation_count ; index++ ) {
49    status = rtems_task_create(
50      rtems_build_name( 'T', 'I', 'M', 'E' ),
51      Task_priority,
52      RTEMS_MINIMUM_STACK_SIZE,
53      RTEMS_DEFAULT_MODES,
54      RTEMS_DEFAULT_ATTRIBUTES,
55      &Task_id[ index ]
56    );
57    directive_failed( status, "rtems_task_create loop" );
58
59    if ( index == operation_count-1 ) task_entry = Last_task;
60    else if ( index == 0 )            task_entry = First_task;
61    else                              task_entry = Middle_tasks;
62
63    status = rtems_task_start( Task_id[ index ], task_entry, 0 );
64    directive_failed( status, "rtems_task_start loop" );
65  }
66
67  Task_count = 1;
68  status = rtems_task_delete( RTEMS_SELF );
69  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
70}
71
72rtems_task First_task(
73  rtems_task_argument argument
74)
75{
76  rtems_task_priority previous_priority;
77
78  benchmark_timer_initialize();
79
80  Task_priority--;
81  Task_count++;
82
83  (void) rtems_task_set_priority(
84           Task_id[ Task_count ],
85           Task_priority,
86           &previous_priority
87         );
88}
89
90rtems_task Middle_tasks(
91  rtems_task_argument argument
92)
93{
94  rtems_task_priority previous_priority;
95
96  Task_priority--;
97  Task_count++;
98
99  (void) rtems_task_set_priority(
100           Task_id[ Task_count ],
101           Task_priority,
102           &previous_priority
103         );
104}
105
106rtems_task Last_task(
107  rtems_task_argument argument
108)
109{
110  uint32_t   index;
111
112  end_time = benchmark_timer_read();
113
114  benchmark_timer_initialize();
115    for ( index=1 ; index < operation_count ; index++ )
116      (void) benchmark_timer_empty_function();
117  overhead = benchmark_timer_read();
118
119  put_time(
120    "rtems_task_set_priority: preempts caller",
121    end_time,
122    operation_count - 1,
123    overhead,
124    CALLING_OVERHEAD_TASK_SET_PRIORITY
125  );
126
127  puts( "*** END OF TEST 17 ***" );
128  rtems_test_exit( 0 );
129}
Note: See TracBrowser for help on using the repository browser.