|
Programming with DTS
There are two ways a programmer can be affected by the presence of DTS in a system. It is possible for an application to retrieve the time from the system in the same way as before DTS
was introduced. But with DTS, the system's time is more correct, and is synchronized with other nodes' clocks in the distributed system.
It is also possible for the programmer to use the DTS API to directly deal with distributed time. Since DTS time is represented differently than single-node time - it includes inaccuracy - new
routines are provided for comparing times and for converting from DTS time format to the native system's time format. The API also includes routines for retrieving the current time, performing
calculations on times, and handling time zone information.
If programmers choose to use DTS directly, they must handle a new contingency when comparing times. When asking the question "Which time is earlier, Time A or Time B?" it is possible to get the
answer "We do not know." When the two time intervals overlap, there is no way of determining which occurred first. Programmers can handle this in two ways: they can ignore the inaccuracy and
compare the two median times; or (the safer alternative) they can acknowledge that either time could have been first, and take the more conservative action. For example, if it cannot be determined,
when running the make program, whether the source or the executable was modified last, the compilation can be rerun, just in case the source was modified after the executable was generated.
|