OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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_task Test_task(
17
  rtems_task_argument argument
18
);
19
 
20
rtems_task Init(
21
  rtems_task_argument argument
22
)
23
{
24
  rtems_status_code status;
25
 
26
  Print_Warning();
27
 
28
  puts( "\n\n*** TIME TEST 1 ***" );
29
 
30
  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
31
  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
32
  Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
33
 
34
  status = rtems_task_create(
35
    Task_name[ 1 ],
36
    128,
37
    RTEMS_MINIMUM_STACK_SIZE,
38
    RTEMS_DEFAULT_MODES,
39
    RTEMS_DEFAULT_ATTRIBUTES,
40
    &Task_id[ 1 ]
41
  );
42
  directive_failed( status, "rtems_task_create of TA1" );
43
 
44
  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
45
  directive_failed( status, "rtems_task_start of TA1" );
46
 
47
  status = rtems_task_delete( RTEMS_SELF );
48
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
49
 
50
}
51
 
52
rtems_task Test_task(
53
  rtems_task_argument argument
54
)
55
{
56
  rtems_unsigned32  semaphore_obtain_time;
57
  rtems_unsigned32  semaphore_release_time;
58
  rtems_unsigned32  semaphore_obtain_no_wait_time;
59
  rtems_unsigned32  semaphore_obtain_loop_time;
60
  rtems_unsigned32  semaphore_release_loop_time;
61
  rtems_unsigned32  index;
62
  rtems_unsigned32  iterations;
63
  rtems_name        name;
64
  rtems_id          smid;
65
  rtems_status_code status;
66
 
67
  name = rtems_build_name( 'S', 'M', '1', ' ' );
68
 
69
  semaphore_obtain_time          = 0;
70
  semaphore_release_time         = 0;
71
  semaphore_obtain_no_wait_time  = 0;
72
  semaphore_obtain_loop_time     = 0;
73
  semaphore_release_loop_time    = 0;
74
 
75
 
76
  /* Time one invocation of rtems_semaphore_create */
77
 
78
  Timer_initialize();
79
    (void) rtems_semaphore_create(
80
      name,
81
      OPERATION_COUNT,
82
      RTEMS_DEFAULT_MODES,
83
      RTEMS_NO_PRIORITY,
84
      &smid
85
    );
86
  end_time = Read_timer();
87
  put_time(
88
    "rtems_semaphore_create",
89
    end_time,
90
    1,
91
    0,
92
    CALLING_OVERHEAD_SEMAPHORE_CREATE
93
  );
94
 
95
  /* Time one invocation of rtems_semaphore_delete */
96
 
97
  Timer_initialize();
98
    (void) rtems_semaphore_delete( smid );
99
  end_time = Read_timer();
100
  put_time(
101
    "rtems_semaphore_delete",
102
    end_time,
103
    1,
104
    0,
105
    CALLING_OVERHEAD_SEMAPHORE_CREATE
106
  );
107
 
108
  status = rtems_semaphore_create(
109
    name,
110
    OPERATION_COUNT,
111
    RTEMS_DEFAULT_ATTRIBUTES,
112
    RTEMS_NO_PRIORITY,
113
    &smid
114
  );
115
 
116
  for ( iterations=OPERATION_COUNT ; iterations ; iterations-- ) {
117
 
118
    Timer_initialize();
119
      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
120
        (void) Empty_function();
121
    end_time = Read_timer();
122
 
123
    semaphore_obtain_loop_time  += end_time;
124
    semaphore_release_loop_time += end_time;
125
 
126
    /* rtems_semaphore_obtain (available) */
127
 
128
    Timer_initialize();
129
      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
130
        (void) rtems_semaphore_obtain(
131
          smid,
132
          RTEMS_DEFAULT_OPTIONS,
133
          RTEMS_NO_TIMEOUT
134
        );
135
    end_time = Read_timer();
136
 
137
    semaphore_obtain_time += end_time;
138
 
139
    /* rtems_semaphore_release */
140
 
141
    Timer_initialize();
142
      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
143
        (void) rtems_semaphore_release( smid );
144
    end_time = Read_timer();
145
 
146
    semaphore_release_time += end_time;
147
 
148
    /* semaphore obtain (RTEMS_NO_WAIT) */
149
    Timer_initialize();
150
      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
151
        rtems_semaphore_obtain( smid, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT );
152
    semaphore_obtain_no_wait_time += Read_timer();
153
 
154
    Timer_initialize();
155
      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
156
        rtems_semaphore_release( smid );
157
    end_time = Read_timer();
158
 
159
    semaphore_release_time += end_time;
160
  }
161
 
162
  put_time(
163
    "rtems_semaphore_obtain: available",
164
    semaphore_obtain_time,
165
    OPERATION_COUNT * OPERATION_COUNT,
166
    semaphore_obtain_loop_time,
167
    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
168
  );
169
 
170
  put_time(
171
    "rtems_semaphore_obtain: not available -- NO_WAIT",
172
    semaphore_obtain_no_wait_time,
173
    OPERATION_COUNT * OPERATION_COUNT,
174
    semaphore_obtain_loop_time,
175
    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
176
  );
177
 
178
  put_time(
179
    "rtems_semaphore_release: no waiting tasks",
180
    semaphore_release_time,
181
    OPERATION_COUNT * OPERATION_COUNT * 2,
182
    semaphore_release_loop_time * 2,
183
    CALLING_OVERHEAD_SEMAPHORE_RELEASE
184
  );
185
 
186
  puts( "*** END OF TEST 1 ***" );
187
  exit( 0 );
188
}

powered by: WebSVN 2.1.0

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