-
type Time_Span is private;
Time_Span_First : constant Time_Span;
Time_Span_Last : constant Time_Span;
Time_Span_Zero : constant Time_Span;
Time_Span_Unit : constant Time_Span;
-
Tick : constant Time_Span;
function Clock return Time;
-
function "+" (Left : Time; Right : Time_Span) return Time;
function "+" (Left : Time_Span; Right : Time) return Time;
function "-" (Left : Time; Right : Time_Span) return Time;
function "-" (Left : Time; Right : Time) return Time_Span;
-
function "<" (Left, Right : Time) return Boolean;
function "<="(Left, Right : Time) return Boolean;
function ">" (Left, Right : Time) return Boolean;
function ">="(Left, Right : Time) return Boolean;
-
function "+" (Left, Right : Time_Span) return Time_Span;
function "-" (Left, Right : Time_Span) return Time_Span;
function "-" (Right : Time_Span) return Time_Span;
function "*" (Left : Time_Span; Right : Integer) return Time_Span;
function "*" (Left : Integer; Right : Time_Span) return Time_Span;
function "/" (Left, Right : Time_Span) return Integer;
function "/" (Left : Time_Span; Right : Integer) return Time_Span;
-
function "abs"(Right : Time_Span) return Time_Span;
-
function "<" (Left, Right : Time_Span) return Boolean;
function "<="(Left, Right : Time_Span) return Boolean;
function ">" (Left, Right : Time_Span) return Boolean;
function ">="(Left, Right : Time_Span) return Boolean;
-
function To_Duration (TS : Time_Span) return Duration;
function To_Time_Span (D : Duration) return Time_Span;
-
function Nanoseconds (NS : Integer) return Time_Span;
function Microseconds (US : Integer) return Time_Span;
function Milliseconds (MS : Integer) return Time_Span;
-
type Seconds_Count is range implementation-defined;
-
procedure Split(T : in Time;
SC : out Seconds_Count;
TS : out Time_Span);
function Time_Of(SC : Seconds_Count; TS : Time_Span) return Time;
-
private
... -- not specified by the language
end Ada.Real_Time;
-
In this Annex, real time is defined to be the physical time as observed
in the external environment. The type Time is a time type as defined by
See section 9.6 Delay Statements, Duration, and Time, values of this type may be used in a delay_until_statement.
Values of this type represent segments of an ideal time line. The set of
values of the type Time corresponds one-to-one with an
implementation-defined range of mathematical integers.
-
The Time value I represents the half-open real time interval that starts
with E+I*Time_Unit and is limited by E+(I+1)*Time_Unit, where Time_Unit
is an implementation-defined real number and E is an unspecified origin
point, the epoch, that is the same for all values of the type Time. It
is not specified by the language whether the time values are
synchronized with any standard time reference. For example, E can
correspond to the time of system initialization or it can correspond to
the epoch of some time standard.
-
Values of the type Time_Span represent length of real time duration. The
set of values of this type corresponds one-to-one with an
implementation-defined range of mathematical integers. The Time_Span
value corresponding to the integer I represents the real-time duration
I*Time_Unit.
-
Time_First and Time_Last are the smallest and largest values of the Time
type, respectively. Similarly, Time_Span_First and Time_Span_Last are
the smallest and largest values of the Time_Span type, respectively.
-
A value of type Seconds_Count represents an elapsed time, measured in
seconds, since the epoch.
Dynamic Semantics
-
Time_Unit is the smallest amount of real time representable by the Time
type; it is expressed in seconds. Time_Span_Unit is the difference
between two successive values of the Time type. It is also the smallest
positive value of type Time_Span. Time_Unit and Time_Span_Unit represent
the same real time duration. A clock tick is a real time interval during
which the clock value (as observed by calling the Clock function)
remains constant. Tick is the average length of such intervals.
-
The function To_Duration converts the value TS to a value of type
Duration. Similarly, the function To_Time_Span converts the value D to a
value of type Time_Span. For both operations, the result is rounded to
the nearest exactly representable value (away from zero if exactly
halfway between two exactly representable values).
-
To_Duration(Time_Span_Zero) returns 0.0, and To_Time_Span(0.0) returns
Time_Span_Zero.
-
The functions Nanoseconds, Microseconds, and Milliseconds convert the
input parameter to a value of the type Time_Span. NS, US, and MS are
interpreted as a number of nanoseconds, microseconds, and milliseconds
respectively. The result is rounded to the nearest exactly representable
value (away from zero if exactly halfway between two exactly
representable values).
-
The effects of the operators on Time and Time_Span are as for the
operators defined for integer types.
-
The function Clock returns the amount of time since the epoch.
-
The effects of the Split and Time_Of operations are defined as follows,
treating values of type Time, Time_Span, and Seconds_Count as
mathematical integers. The effect of Split(T,SC,TS) is to set SC and TS
to values such that T*Time_Unit = SC*1.0 + TS*Time_Unit, and 0.0 <=
TS*Time_Unit < 1.0. The value returned by Time_Of(SC,TS) is the value T
such that T*Time_Unit = SC*1.0 + TS*Time_Unit.
Implementation Requirements
-
The range of Time values shall be sufficient to uniquely represent the
range of real times from program start-up to 50 years later. Tick shall
be no greater than 1 millisecond. Time_Unit shall be less than or equal
to 20 microseconds.
-
Time_Span_First shall be no greater than -3600 seconds, and
Time_Span_Last shall be no less than 3600 seconds.
-
A clock jump is the difference between two successive distinct values of
the clock (as observed by calling the Clock function). There shall be no
backward clock jumps.
Documentation Requirements
-
The implementation shall document the values of Time_First, Time_Last,
Time_Span_First, Time_Span_Last, Time_Span_Unit, and Tick.
-
The implementation shall document the properties of the underlying time
base used for the clock and for type Time, such as the range of values
supported and any relevant aspects of the underlying hardware or
operating system facilities used.
-
The implementation shall document whether or not there is any
synchronization with external time references, and if such
synchronization exists, the sources of synchronization information, the
frequency of synchronization, and the synchronization method applied.
-
The implementation shall document any aspects of the the external
environment that could interfere with the clock behavior as defined in
this clause.
Metrics
-
For the purpose of the metrics defined in this clause, real time is
defined to be the International Atomic Time (TAI).
-
The implementation shall document the following metrics:
-
An upper bound on the real-time duration of a clock tick. This is
a value D such that if t1 and t2 are any real times such that t1 <
t2 and Clock = Clock then t2 - t1 <= D.
t1 t2
-
An upper bound on the size of a clock jump.
-
An upper bound on the drift rate of Clock with respect to real time.
This is a real number D such that
-
E*(1-D) <= (Clock - Clock ) <= E*(1+D)
t+E t
provided that: Clock + E*(1+D) <= Time_Last.
t
-
where Clock is the value of Clock at time t, and E is a real time
t
time duration not less than 24 hours. The value of E used for this
metric shall be reported. @end format
-
An upper bound on the execution time of a call to the Clock function, in
processor clock cycles.
-
Upper bounds on the execution times of the operators of the types Time
and Time_Span, in processor clock cycles.