ThreadX scheduling overhead

HugPeter-9392 246 Reputation points
2022-03-07T16:01:11.51+00:00

Hello

I was asked to quantify how many CPU cycles are required for scheduling. I'm going to do an initial development for a series of devices. Could someone guide me to a place where I can find the number of CPU cycles to do the following:

  • Preempt low priority thread and schedule high priority thread.
  • Schedule from thread to thread on same priority. E.g. first thread blocked on a semaphore.
  • Schedule from inactivated (e.g. blocking on a semaphore) high priority thread to low priority pending thread.
  • Number of cycles from interrupt becoming active until first instruction of the user interrupt handler.
  • Schedule from end of interrupt back to the thread preempted by this interrupt.
  • Schedule from end of interrupt to a task higher than the thread that the interrupt has preempted.
  • For how many CPU cycles get interrupts disabled while scheduling?

I expect the applications will run under the following:

  • Cortex-M0+/M4/M7 depending on the enabled features.
  • A typical configuration for an application with 16-64 tasks and 8 priority levels
  • How much adds an FPU?
  • How much adds an MMU/MPU?

Thanks very much

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
{count} votes

Answer accepted by question author
  1. Scott Azure RTOS 4,051 Reputation points
    2022-03-07T21:33:31.593+00:00

    Hi @HugPeter-9392

    We don't have exact cycle counts measured, but you should be able to do that with the cycle counter hardware or an accurate simulator. Here are some sizes and timing measurements for an M7 core running at 216 MHz:

    180718-image.png

    For an FPU, there will be additional cycles required to save/restore the FPU registers when context switching. For an MPU, you'll have to use ThreadX Modules, and we do not have any benchmarks for Modules yet.


1 additional answer

Sort by: Most helpful
  1. HugPeter-9392 246 Reputation points
    2022-03-10T14:50:34.097+00:00

    Just to make sure. The total time required from end to end is the TRCS information. All other measurements are details included in TRCS.

    Example:

    • High priority thread A is waiting on a semaphore.
    • Low priority thread B holds that semaphore.
    • Low priority thread B calls tx_semaphore_put to release ownership to the shared semaphore.
    • In this situation, thread A preempts thread B.

    Then the TRCS value (1.1us) gives the time beginning when thread A calls tx_semaphore_put until thread B resumes. In this situation, it is when thread B returns from its call to tx_semaphore_get.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.