Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 3.05

µC/OS-III provides facilities to measure the amount of time the scheduler is locked. This is done by setting the configuration constant OS_CFG_SCHED_LOCK_TIME_MEAS_EN to 1 DEF_ENABLED in os_cfg.h.

The measurement is started each time the scheduler is locked and ends when the scheduler is unlocked. The measurement keeps track of two values: a global scheduler lock time, and a per-task scheduler lock time. It is therefore possible to know how long each task locks the scheduler allowing the user to better optimize code.

The per-task scheduler lock time is saved in the task’s OS_TCB during a context switch (see OSTaskSwHook() in os_cpu_c.c and described in Chapter 8, “Context Switching” Context Switching).

The unit of measure for the measured time is in CPU_TS (timestamp) units so it is necessary to find the resolution of the timer used to measure the timestamps. For example, if the timer used for the timestamp is incremented at 1 MHz then the resolution of CPU_TS is 1 microsecond.

...