CPU load: Correct computation of the nominal period to use when the source is a oneshot timer.
This commit is contained in:
parent
1e38884088
commit
686041f8e7
@ -654,8 +654,8 @@ config CPULOAD_ONESHOT_ENTROPY
|
||||
|
||||
Where
|
||||
|
||||
CPULOAD_ONESHOT_NOMINAL is CONFIG_SCHED_CPULOAD_TICKSPERSEC in
|
||||
units of microseconds.
|
||||
CPULOAD_ONESHOT_NOMINAL is the nominal sample internval implied
|
||||
by CONFIG_SCHED_CPULOAD_TICKSPERSEC in units of microseconds.
|
||||
CPULOAD_ONESHOT_ENTROPY is (1 << CONFIG_CPULOAD_ONESHOT_ENTROPY),
|
||||
and
|
||||
'error' is an error value that is retained from interval to
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* sched/sched/sched_cpuload_oneshot.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -56,25 +56,43 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#if !defined(CONFIG_SCHED_CPULOAD) || !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
# error CONFIG_SCHED_CPULOAD and CONFIG_SCHED_CPULOAD_EXTCLK must be defined
|
||||
#endif
|
||||
|
||||
/* CONFIG_SCHED_CPULOAD_TICKSPERSEC is the frequency of the external clock
|
||||
* source.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_SCHED_CPULOAD_TICKSPERSEC
|
||||
# error CONFIG_SCHED_CPULOAD_TICKSPERSEC not defined
|
||||
#endif
|
||||
|
||||
#define CPULOAD_ONESHOT_NOMINAL (CONFIG_SCHED_CPULOAD_TICKSPERSEC * 1000)
|
||||
|
||||
#if CPULOAD_ONESHOT_NOMINAL < 1 || CPULOAD_ONESHOT_NOMINAL > 0x7fffffff
|
||||
# error CPULOAD_ONESHOT_NOMINAL is out of range
|
||||
#endif
|
||||
/* CONFIG_CPULOAD_ONESHOT_ENTROPY determines that amount of random "jitter"
|
||||
* that will be added to the nominal sample interval. Specified as a number
|
||||
* bits.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_CPULOAD_ONESHOT_ENTROPY
|
||||
# warning CONFIG_CPULOAD_ONESHOT_ENTROPY not defined
|
||||
# define CONFIG_CPULOAD_ONESHOT_ENTROPY 0
|
||||
#endif
|
||||
|
||||
/* Calculate the nomimal sample interval in microseconds:
|
||||
*
|
||||
* nominal = (1,000,000 usec/sec) / Frequency cycles/sec) = Period usec/cycle
|
||||
*/
|
||||
|
||||
#define CPULOAD_ONESHOT_NOMINAL (1000000 / CONFIG_SCHED_CPULOAD_TICKSPERSEC)
|
||||
|
||||
#if CPULOAD_ONESHOT_NOMINAL < 1 || CPULOAD_ONESHOT_NOMINAL > 0x7fffffff
|
||||
# error CPULOAD_ONESHOT_NOMINAL is out of range
|
||||
#endif
|
||||
|
||||
/* Convert the entropy from number of bits to a numeric value */
|
||||
|
||||
#define CPULOAD_ONESHOT_ENTROPY (1 << CONFIG_CPULOAD_ONESHOT_ENTROPY)
|
||||
|
||||
#if CPULOAD_ONESHOT_NOMINAL < CPULOAD_ONESHOT_ENTROPY
|
||||
|
Loading…
Reference in New Issue
Block a user