z/TPF

z/TPF

z/TPF

The z/TPF group is dedicated to sharing news, knowledge, and insights about the z/TPF product family. Consisting of IBMers and users, this community collaborates to advance the potential of high-volume, high-throughput transaction technology.

 View Only

Extended TOD clock value conversion (PJ46952)

By Timothy Backus posted Fri February 24, 2023 03:59 PM

  

The TOD clock is the primary method of timekeeping on TPF. There are 3 instructions that will obtain the TOD clock. The STCK and STCKF instructions return an 8-byte TOD clock value, and the STCKE instruction returns a 16-byte TOD clock value. On September 17, 2042 the 8-byte TOD clock value will wrap to zero.

The UNIX epoch timestamp (time_t) is also an 8-byte value, but it can represent timestamps well beyond 2042 as it only increments every second. Currently, the tpf_STCK_to_timet function converts an 8-byte TOD clock value into a time_t value. If the 8-byte TOD clock value wraps and this value is used by the tpf_STCK_to_timet function, the resulting time_t value will represent an time that already passed. This could introduce issues when time_t values are compared.

To mitigate the wrapping issue, the STCKE instruction can be used to get a 16-byte TOD clock value (an extended TOD value). The 16-byte TOD clock value features an epoch byte, which increments every time the value of the TOD clock wraps, and offers more precision. With this, you can represent timestamps beyond 2042. Before PJ46952, conversion between the extended TOD clock value and time_t value was not possible.

With APAR PJ46952, you can use the tpf_timet_to_STCKE and tpf_STCKE_to_timet functions to convert between a 16-byte TOD clock value and a time_t value. These functions use the epoch byte in the extended TOD clock to correctly convert to and from time_t values, even if the timestamp is beyond the year 2042.

For more information about APAR PJ46952, see the APEDIT or see the z/TPF product documentation.

0 comments
22 views

Permalink