Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Oneshot Timers and CPU Load Measurement

Issues with CPU Load Measurement

There is been support for CPU load measurement for a long time. Enabled with:

...

  • Sample at times are completely random with respect to program behavior, and
  • Sample at a high rate or for a very long time.

External Clock

In order to work around these things, an option to use an external clock was added:

...

This should work well if CONFIG_SCHED_CPULOAD_TICKSPERSEC is prime and less than CONFIG_USEC_PER_TICK.
However, you were completely on your own one how to implement this external clock. But no longer.

Using a Oneshot Timer to Drive CPU Load Measurement

Recently, a generic, platform-independent one-shot lower half interface was developed. That interface is described in include/nuttx/timers/oneshot.h. There are implementations of the one shot timer lower half available for STM32, STM32L4, SAM4CM, SAMA5D3/4, and SAMV71/SAME70.

...

sched_oneshot_extclk() is prototyped in include/nuttx/clock.h. There is some example setup code in the NuttX simulation code at boards/sim/sim/sim/src/sim_bringup.c.

Entropy

Another recent addition to NuttX came from David Alessio. David contributed support for /dev/urandom with a built-in XorShift128 pseduo-random number generator (PRNG). I have detached the XorShift128 implementation from the /dev/urandom implementation and moved it to /libc/misc so that is it available for other purposes.

...