TIMER: Fix sim_idle_ms_sleep() return value to be more precise
delta time computation converting the difference between two timespec structures values to milliseconds previously truncated the difference which, depending on the value of when the starting value in the delta happened, along with when an OS clock tick occurred, may have resulted in a small delta and an apparent sleep time of 0. A more accurate result is produced when the conversion from nanoseconds to milliseconds is rounded up before the usecs/nsecs are truncated.
This commit is contained in:
parent
4313f9fe3c
commit
7ebd22edaa
1 changed files with 1 additions and 1 deletions
|
@ -312,7 +312,7 @@ if (!timedout) {
|
|||
AIO_UPDATE_QUEUE;
|
||||
}
|
||||
sim_timespec_diff (&delta_time, &done_time, &start_time);
|
||||
delta_ms = (uint32)((delta_time.tv_sec * 1000) + (delta_time.tv_nsec / 1000000));
|
||||
delta_ms = (uint32)((delta_time.tv_sec * 1000) + ((delta_time.tv_nsec + 500000) / 1000000));
|
||||
return delta_ms;
|
||||
}
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue