mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Correct round-to-ticks logic in sigtimedwait()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5457 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -3812,4 +3812,7 @@
|
|||||||
* include/pthread.h: In sys/prctl.h because it is needed by
|
* include/pthread.h: In sys/prctl.h because it is needed by
|
||||||
pthread_[set|get]name_np()
|
pthread_[set|get]name_np()
|
||||||
* tools/kconfig.bat: Kludge to run kconfig-frontends from a DOS shell.
|
* tools/kconfig.bat: Kludge to run kconfig-frontends from a DOS shell.
|
||||||
|
* sched/sig_timedwait.c: Should always move the time up to the next
|
||||||
|
largest number of system ticks. The logic was rounding. Noted by
|
||||||
|
Petteri Aimonen.
|
||||||
|
|
||||||
|
|||||||
+19
-3
@@ -238,10 +238,25 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||||||
|
|
||||||
if (timeout)
|
if (timeout)
|
||||||
{
|
{
|
||||||
/* Convert the timespec to milliseconds */
|
/* Convert the timespec to system clock ticks, making sure that
|
||||||
|
* the resultint delay is greater than or equal to the requested
|
||||||
|
* time in nanoseconds.
|
||||||
|
*/
|
||||||
|
|
||||||
waitticks = MSEC2TICK(timeout->tv_sec * MSEC_PER_SEC
|
#ifdef CONFIG_HAVE_LONG_LONG
|
||||||
+ timeout->tv_nsec / NSEC_PER_MSEC);
|
uint64_t waitticks64 = (timeout->tv_sec * NSEC_PER_SEC +
|
||||||
|
timeout->tv_nsec + NSEC_PER_TICK - 1) /
|
||||||
|
NSEC_PER_TICK;
|
||||||
|
DEBUGASSERT(waitticks64 <= UINT32_MAX);
|
||||||
|
waitticks = (uint32_t)waitticks64;
|
||||||
|
#else
|
||||||
|
uint32_t waitmsec;
|
||||||
|
|
||||||
|
DEBUGASSERT(timeout->tv_sec < UINT32_MAX / MSEC_PER_SEC);
|
||||||
|
waitmsec = timeout->tv_sec * MSEC_PER_SEC +
|
||||||
|
(timeout->tv_nsec + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC;
|
||||||
|
waitticks = (waitmsec + MSEC_PER_TICK - 1) / MSEC_PER_TICK;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Create a watchdog */
|
/* Create a watchdog */
|
||||||
|
|
||||||
@@ -326,6 +341,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||||||
{
|
{
|
||||||
memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo));
|
memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(saved_state);
|
irqrestore(saved_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user