Fix calculations using MSEC_PER_TICK. If USEC_PER_TICK is less than 1000, then MSEC_PER_TICK will be zero. It will be inaccurate in any case.

This commit is contained in:
Gregory Nutt 2016-09-25 08:17:33 -06:00
parent 25cd684012
commit 0908a6c6b9
4 changed files with 8 additions and 9 deletions

View File

@ -3915,7 +3915,7 @@ void sched_process_timer(void);
The timer interrupt logic itself is implemented in the
architecture specific code, but must call the following OS
function periodically -- the calling interval must be
<code>MSEC_PER_TICK</code>.
<code>CONFIG_USEC_PER_TICK</code>.
</p>
<h3><a name="schedtimerexpiration">4.8.4 <code>sched_timer_expiration()</code></a></h3>

View File

@ -434,8 +434,8 @@ static void slip_txtask(int argc, FAR char *argv[])
FAR struct slip_driver_s *priv;
unsigned int index = *(argv[1]) - '0';
net_lock_t flags;
systime_t msec_start;
systime_t msec_now;
systime_t start_ticks;
systime_t now_ticks;
unsigned int hsec;
nerr("index: %d\n", index);
@ -450,7 +450,7 @@ static void slip_txtask(int argc, FAR char *argv[])
/* Loop forever */
msec_start = clock_systimer() * MSEC_PER_TICK;
start_ticks = clock_systimer();
for (; ; )
{
/* Wait for the timeout to expire (or until we are signaled by by */
@ -484,14 +484,14 @@ static void slip_txtask(int argc, FAR char *argv[])
/* Has a half second elapsed since the last timer poll? */
msec_now = clock_systimer() * MSEC_PER_TICK;
hsec = (unsigned int)(msec_now - msec_start) / (MSEC_PER_SEC / 2);
now_ticks = clock_systimer();
hsec = (unsigned int)(now_ticks - start_ticks) / TICK_PER_HSEC;
if (hsec)
{
/* Yes, perform the timer poll */
(void)devif_timer(&priv->dev, slip_txpoll);
msec_start += hsec * (MSEC_PER_SEC / 2);
start_ticks += hsec * TICK_PER_HSEC;
}
else
{

View File

@ -54,7 +54,6 @@
* Pre-processor Definitions
****************************************************************************/
#define NFS_TICKINTVL MSEC_PER_TICK /* Smallest that we can get */
#define NFS_TICKS 1 /* Number of system ticks */
#define NFS_HZ CLOCKS_PER_SEC /* Ticks/sec */
#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */

View File

@ -1934,7 +1934,7 @@ void up_cxxinitialize(void);
* CONFIG_SCHED_TICKLESS is *not* defined). The timer interrupt logic
* itself is implemented in the architecture specific code, but must call
* the following OS function periodically -- the calling interval must
* be MSEC_PER_TICK.
* be CONFIG_USEC_PER_TICK.
*
****************************************************************************/