You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/11/03 14:01:44 UTC

[GitHub] [incubator-nuttx] jlaitine commented on a change in pull request #4779: libs/libc/wqueue/work_usrthread.c: Correct time calculation in work_p…

jlaitine commented on a change in pull request #4779:
URL: https://github.com/apache/incubator-nuttx/pull/4779#discussion_r741969232



##########
File path: libs/libc/wqueue/work_usrthread.c
##########
@@ -193,15 +193,18 @@ static void work_process(FAR struct usr_wqueue_s *wqueue)
     {
       struct timespec rqtp;
       time_t sec;
+      uint64_t nsec;
 
       /* 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, &rqtp);
+      nsec = 1000 * TICK2USEC(next);
+      sec = nsec / (1000 * 1000 * 1000);
+      rqtp.tv_sec  += sec;
+      rqtp.tv_nsec += (uint32_t)(nsec - sec * 1000 * 1000 * 1000);

Review comment:
       Thanks, agree on all points. Will fix this :)
   
   
   
   




-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org