summaryrefslogtreecommitdiffstats
path: root/doc/FAQ/endoftime.t
blob: 5f6d3592ca492b20e6bb80a6f02636c374217116 (plain) (blame)
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
@c
@c  COPYRIGHT (c) 1988-1999.
@c  On-Line Applications Research Corporation (OAR).
@c  All rights reserved.
@c
@c  $Id$
@c

@chapter Date/Time Issues in Systems Using RTEMS

This section provides technical information regarding
date/time representation issues and RTEMS.  The Y2K problem has
lead numerous people to ask these questions.  The answer to
these questions are actually more complicated than most 
people asking the question expect.  RTEMS supports multiple
standards and each of these standards has its own epoch and
time representation.  These standards include both programming
API and programming language standards.

In addition to the issues inside RTEMS
itself, there is the complicating factor that the Board
Support Package or application itself may interface with hardware
or software that has its own set of date/time representation
issues.  

In conclusion, viewing date/time representation as "the Y2K problem"
is very short-sighted.  Date/time representation should be viewed as
a systems level issue for the system you are building.  Each software
and hardware component in the system as well as the systems being
connected to is a factor in the equation.

@section Hardware Issues

Numerous Real-Time Clock (RTC) controllers provide only a two-digit
Binary Coded Decimal (BCD) representation for the current year.  Without
software correction, these chips are a classic example of the Y2K problem.
When the RTC rolls the year register over from 99 to 00, the device
has no idea whether the year is 1900 or 2000.  It is the responsibility
of the device driver to recognize this condition and correct for it.
The most common technique used is to assume that all years prior
to either the existence of the board or RTEMS are past 2000.  The
starting year (epoch) for RTEMS is 1988.  Thus,

@itemize @bullet
@item Chip year values 88-99 are interpreted as years 1988-1999.
@item Chip year values 00-87 are interpreted as years 2000-2087.
@end itemize

Using this technique, a RTC using a
two-digit BCD representation of the current year will overflow on
January 1, 2088.

@section RTEMS Specific Issues

Internally, RTEMS uses an unsigned thirty-two bit integer to represent the
number of seconds since midnight January 1, 1988.  This counter will
overflow on February 5, 2124. 

The time/date services in the Classic API will overflow when the 
RTEMS internal date/time representation overflows.

The POSIX API uses the type @i{time_t} to represent the number of
seconds since January 1, 1970.  Many traditional UNIX systems as
well as RTEMS define @i{time_t} as a signed thirty-two bit integer.
This representation overflows on January 18, 2038.  The solution
usually proposed is to define @i{time_t} as a sixty-four bit
integer.  This solution is appropriate for for UNIX workstations
as many of them already support sixty-four bit integers natively.
At this time, this imposes a burden on embedded systems which are
still primarily using processors with native integers of thirty-two
bits or less.

@section Language Specific Issues

The Ada95 Language Reference Manual requires that the @i{Ada.Calendar}
package support years through the year 2099.  However, just as the
hardware is layered on top of hardware and may inherit its limits,
the Ada tasking and run-time support is layered on top of an operating
system.  Thus, if the operating system or underlying hardware fail
to correctly report dates after 2099, then it is possible for the
@i{Ada.Calendar} package to fail prior to 2099.

@section Date/Time Conclusion

Each embedded system could be impacted by a variety of date/time
representation issues.  Even whether a particular date/time
repsentation issue impacts a system is questionable.  A system
using only the RTEMS Classic API is not impacted by the
date/time representation issues in POSIX.  A system not using
date/time at all is not impacted by any of these issues.  Also
the planned end of life for a system may make these issues
moot.

The following is a timeline of the date/time representation
issues presented in this section:

@itemize @bullet

@item 2000 - Two BCD Digit Real-Time Clock Rollover

@item 2038 - POSIX @i{time_t} Rollover

@item 2088 - Correction for Two BCD Digit Real-Time Clock Rollover

@item 2099 - Ada95 @i{Ada.Calendar} Rollover

@item 2124 - RTEMS Internal Seconds Counter Rollover

@end itemize