1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
--
-- SPTEST / BODY
--
-- DESCRIPTION:
--
-- This package is the implementation of the Nanosecond test of the
-- Sample Test Suite.
--
-- DEPENDENCIES:
--
--
--
-- COPYRIGHT (c) 1989-2009.
-- On-Line Applications Research Corporation (OAR).
--
-- The license and distribution terms for this file may in
-- the file LICENSE in this distribution or at
-- http://www.rtems.com/license/LICENSE.
--
-- $Id$
--
with Ada.Integer_Text_IO;
with Interfaces.C;
with RTEMS;
with Text_IO;
use type Interfaces.C.Long;
use type RTEMS.Time_T;
package body SPTEST is
Dummy_Variable : Natural := 0;
procedure Simple_Procedure is
begin
Dummy_Variable := Dummy_Variable + 1;
end Simple_Procedure;
procedure Subtract_Em (
Start : in RTEMS.Timespec;
Stop : in RTEMS.Timespec;
Result : out RTEMS.Timespec
) is
Nanoseconds_Per_Second : constant := 1000000000;
begin
if (Stop.TV_Nsec < Start.TV_Nsec) then
Result.TV_Sec := Stop.TV_Sec - Start.TV_Sec - 1;
Result.TV_Nsec :=
(Nanoseconds_Per_Second - Start.TV_Nsec) + Stop.TV_Nsec;
else
Result.TV_Sec := Stop.TV_Sec - Start.TV_Sec;
Result.TV_Nsec := Stop.TV_Nsec - Start.TV_Nsec;
end if;
end Subtract_Em;
--PAGE
--
-- INIT
--
procedure INIT (
ARGUMENT : in RTEMS.TASK_ARGUMENT
) is
pragma Unreferenced(ARGUMENT);
Status : RTEMS.Status_Codes;
Start : RTEMS.Timespec;
Stop : RTEMS.Timespec;
Diff : RTEMS.Timespec;
Max : Integer;
begin
TEXT_IO.NEW_LINE( 2 );
TEXT_IO.PUT_LINE( "*** NANOSECOND CLOCK TEST ***" );
--
-- Iterate 10 times showing difference in TOD
--
TEXT_IO.PUT_LINE( "10 iterations of getting TOD NOT tested in Ada" );
--
-- Iterate 10 times showing difference in Uptime
--
TEXT_IO.NEW_LINE;
TEXT_IO.PUT_LINE( "10 iterations of getting Uptime" );
for Index in 1 .. 10 loop
RTEMS.Clock_Get_Uptime( Start, Status );
RTEMS.Clock_Get_Uptime( Stop, Status );
Subtract_Em( Start, Stop, Diff );
Ada.Integer_Text_IO.Put( Integer( Start.TV_Sec ), 1 );
Text_IO.Put( ":" );
Ada.Integer_Text_IO.Put( Integer( Start.TV_Nsec ), 9 );
Text_IO.Put( " " );
Ada.Integer_Text_IO.Put( Integer( Stop.TV_Sec ), 1 );
Text_IO.Put( ":" );
Ada.Integer_Text_IO.Put( Integer( Stop.TV_Nsec ), 9 );
Text_IO.Put( " --> " );
Ada.Integer_Text_IO.Put( Integer( Diff.TV_Sec ), 1 );
Text_IO.Put( ":" );
Ada.Integer_Text_IO.Put( Integer( Diff.TV_Nsec ), 9 );
Text_IO.New_Line;
end loop;
--
-- Iterate 10 times showing difference in Uptime with different counts
--
TEXT_IO.NEW_LINE;
TEXT_IO.PUT_LINE(
"10 iterations of getting Uptime with different loop values"
);
for Index in 1 .. 10 loop
Max := (Index * 10000);
RTEMS.Clock_Get_Uptime( Start, Status );
for j in 1 .. Max loop
Simple_Procedure;
end loop;
RTEMS.Clock_Get_Uptime( Stop, Status );
Subtract_Em( Start, Stop, Diff );
Text_IO.Put( "loop of " );
Ada.Integer_Text_IO.Put( Max, 6 );
Text_IO.Put( " " );
Ada.Integer_Text_IO.Put( Integer( Start.TV_Sec ), 1 );
Text_IO.Put( ":" );
Ada.Integer_Text_IO.Put( Integer( Start.TV_Nsec ), 9 );
Text_IO.Put( " " );
Ada.Integer_Text_IO.Put( Integer( Stop.TV_Sec ), 1 );
Text_IO.Put( ":" );
Ada.Integer_Text_IO.Put( Integer( Stop.TV_Nsec ), 9 );
Text_IO.Put( " --> " );
Ada.Integer_Text_IO.Put( Integer( Diff.TV_Sec ), 1 );
Text_IO.Put( ":" );
Ada.Integer_Text_IO.Put( Integer( Diff.TV_Nsec ), 9 );
Text_IO.New_Line;
end loop;
delay( 1.0 );
TEXT_IO.PUT_LINE( "*** END OF NANOSECOND CLOCK TEST ***" );
RTEMS.SHUTDOWN_EXECUTIVE( 0 );
end INIT;
end SPTEST;
|