OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [tmtests/] [tm06/] [task1.c] - Blame information for rev 507

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *
3
 *  COPYRIGHT (c) 1989-1999.
4
 *  On-Line Applications Research Corporation (OAR).
5
 *
6
 *  The license and distribution terms for this file may be
7
 *  found in the file LICENSE in this distribution or at
8
 *  http://www.OARcorp.com/rtems/license.html.
9
 *
10
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:41 chris Exp $
11
 */
12
 
13
#define TEST_INIT
14
#include "system.h"
15
 
16
rtems_id Task_id[ OPERATION_COUNT + 1 ];
17
 
18
rtems_unsigned32 Task_restarted;
19
 
20
rtems_task null_task(
21
  rtems_task_argument argument
22
);
23
 
24
rtems_task Task_1(
25
  rtems_task_argument argument
26
);
27
 
28
void test_init( void );
29
 
30
rtems_task Init(
31
  rtems_task_argument argument
32
)
33
{
34
  rtems_status_code status;
35
 
36
  Print_Warning();
37
 
38
  puts( "\n\n*** TIME TEST 6 ***" );
39
 
40
  test_init();
41
 
42
  status = rtems_task_delete( RTEMS_SELF );
43
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
44
}
45
 
46
void test_init( void )
47
{
48
  rtems_status_code status;
49
  rtems_id id;
50
 
51
  Task_restarted = OPERATION_COUNT;
52
 
53
  status = rtems_task_create(
54
    rtems_build_name( 'T', 'I', 'M', 'E' ),
55
    128,
56
    RTEMS_MINIMUM_STACK_SIZE,
57
    RTEMS_DEFAULT_MODES,
58
    RTEMS_DEFAULT_ATTRIBUTES,
59
    &id
60
  );
61
  directive_failed( status, "rtems_task_create" );
62
 
63
  status = rtems_task_start( id, Task_1, 0 );
64
  directive_failed( status, "rtems_task_start" );
65
}
66
 
67
rtems_task Task_1(
68
  rtems_task_argument argument
69
)
70
{
71
  rtems_status_code status;
72
  rtems_unsigned32  index;
73
 
74
  if ( Task_restarted == OPERATION_COUNT )
75
     Timer_initialize();
76
 
77
  Task_restarted--;
78
 
79
  if ( Task_restarted != 0 )
80
    (void) rtems_task_restart( RTEMS_SELF, 0 );
81
 
82
  end_time = Read_timer();
83
 
84
  Timer_initialize();
85
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
86
      (void) Empty_function();
87
  overhead = Read_timer();
88
 
89
  put_time(
90
    "rtems_task_restart: calling task",
91
    end_time,
92
    OPERATION_COUNT,
93
    overhead,
94
    CALLING_OVERHEAD_TASK_RESTART
95
  );
96
 
97
  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
98
    status = rtems_task_create(
99
      rtems_build_name( 'T', 'I', 'M', 'E' ),
100
      254,
101
      RTEMS_MINIMUM_STACK_SIZE,
102
      RTEMS_DEFAULT_MODES,
103
      RTEMS_DEFAULT_ATTRIBUTES,
104
      &Task_id[ index ]
105
    );
106
    directive_failed( status, "rtems_task_create loop" );
107
 
108
    status = rtems_task_start( Task_id[ index ], null_task, 0 );
109
    directive_failed( status, "rtems_task_start loop" );
110
  }
111
 
112
  Timer_initialize();
113
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
114
      (void) rtems_task_suspend( Task_id[ index ] );
115
  end_time = Read_timer();
116
 
117
  put_time(
118
    "rtems_task_suspend: returns to caller",
119
    end_time,
120
    OPERATION_COUNT,
121
    0,
122
    CALLING_OVERHEAD_TASK_SUSPEND
123
  );
124
 
125
  Timer_initialize();
126
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
127
      (void) rtems_task_resume( Task_id[ index ] );
128
  end_time = Read_timer();
129
 
130
  put_time(
131
    "rtems_task_resume: task readied -- returns to caller",
132
    end_time,
133
    OPERATION_COUNT,
134
    0,
135
    CALLING_OVERHEAD_TASK_RESUME
136
  );
137
 
138
  Timer_initialize();
139
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
140
      (void) rtems_task_delete( Task_id[ index ] );
141
  end_time = Read_timer();
142
 
143
  put_time(
144
    "rtems_task_delete: ready task",
145
    end_time,
146
    OPERATION_COUNT,
147
    0,
148
    CALLING_OVERHEAD_TASK_RESUME
149
  );
150
 
151
  puts( "*** END OF TEST 6 ***" );
152
  exit( 0 );
153
}
154
 
155
rtems_task null_task(
156
  rtems_task_argument argument
157
)
158
{
159
  while ( FOREVER )
160
    ;
161
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.