Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title clock() function stops after 49 days in QNX4.
Ref. No. QNX.000010183
Category(ies) Development
Issue We are using the clock() function for the measurement of small time differences.  Unfortunately the value of clock() stops after 49 days with the value 0xFFFFFFFF and does not turn around as we expected.  Are there any alternatives that do not have such restrictions?
Solution It happens when clock_t reaches the maximum number of ticks, therefore the function returns -1.

NOTE: The number of ticks used to "roll over" when it reached the maximum (approximately every 49 days), but this was a coding error that has been fixed.

The one solution around it, would be:

struct _timesel volatile far *tp = 0;
struct _osinfo info;

if ( qnx_osinfo( 0, &info ) == -1 ) {
    return -1;
}

tp = (struct _timesel volatile far *) MK_FP( info.timesel, 0);

This will allow to read time through tp->nsec and tp->seconds.