patacongo commented on pull request #5421:
URL: https://github.com/apache/incubator-nuttx/pull/5421#issuecomment-1030707769
> That is crappy code (any maybe not even correct), ...
It is certainly not correct. What we want is an error based on the time
that we wanted and the time that we got, then to apply the error to the delay.
Maybe this is closer:
```
clock_t last_time = current_time;
for (; ; )
{
clock_t next_time = last_time + x;
clock_t current_time = clock_systime_ticks();
int error= next_time - current_time;
last_time = next_time;
delay(x + error);
}
```
So after x ticks elapse, and current time is one more the expected time,
then the next delay would be x - 1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]