libs/libc/wqueue/work_usrthread.c: Correct time calculation in work_process
This fixes busylooping in work_usrthread, due to incorrect time spec given to sem_timedwait _SEM_TIMEDWAIT works on absolute time stamps, using CLOCK_REALTIME Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
parent
c79d2067c7
commit
7e9e8a817d
|
@ -191,17 +191,18 @@ static void work_process(FAR struct usr_wqueue_s *wqueue)
|
|||
}
|
||||
else
|
||||
{
|
||||
struct timespec now;
|
||||
struct timespec delay;
|
||||
struct timespec rqtp;
|
||||
time_t sec;
|
||||
|
||||
/* Wait awhile to check the work list. We will wait here until
|
||||
* either the time elapses or until we are awakened by a semaphore.
|
||||
* Interrupts will be re-enabled while we wait.
|
||||
*/
|
||||
|
||||
sec = next / 1000000;
|
||||
rqtp.tv_sec = sec;
|
||||
rqtp.tv_nsec = (next - (sec * 1000000)) * 1000;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
clock_ticks2time(next, &delay);
|
||||
clock_timespec_add(&now, &delay, &rqtp);
|
||||
|
||||
_SEM_TIMEDWAIT(&wqueue->wake, &rqtp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue