You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ((res = (clock_t) _times_r (_REENT, &tim_s)) != (clock_t) -1)
res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime +
tim_s.tms_cutime + tim_s.tms_cstime);
return res;
}
It seems that ticks returned by clock are multiplied by 2, due to in _times_r tms_cstime and tms_stime are set with the current processor ticks. tms_cstime or tms_stime must be set to 0.
The text was updated successfully, but these errors were encountered:
I'm a bit confusing about _times_r implementation.
Current implementation:
clock_t IRAM_ATTR _times_r(struct _reent *r, struct tms *ptms)
{
clock_t t = xTaskGetTickCount() * (portTICK_PERIOD_MS * CLK_TCK / 1000);
ptms->tms_cstime = t;
ptms->tms_cutime = 0;
ptms->tms_stime = t;
ptms->tms_utime = 0;
struct timeval tv = {0, 0};
_gettimeofday_r(r, &tv, NULL);
return (clock_t) tv.tv_sec;
}
In newlibc clock implementation is:
clock_t
clock ()
{
struct tms tim_s;
clock_t res;
if ((res = (clock_t) _times_r (_REENT, &tim_s)) != (clock_t) -1)
res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime +
tim_s.tms_cutime + tim_s.tms_cstime);
return res;
}
It seems that ticks returned by clock are multiplied by 2, due to in _times_r tms_cstime and tms_stime are set with the current processor ticks. tms_cstime or tms_stime must be set to 0.
The text was updated successfully, but these errors were encountered: