ThreadX SMP Thread Blocking Lower Priority Threads Despite Cores Being Available

Collin 0 Reputation points
2023-03-08T18:35:59.12+00:00

I had previously asked a related question to the topic found here. From that, I was able to get a working port of ThreadX SMP for the hardware I am using. Using that port, I then proceeded to run the test that gave me issues initially and I am seeing the same unexpected behavior. The situation is as follows:

  • Have 1 thread with a preemption threshold set higher than its priority and no time slice.
  • Have some number of other threads (I'm using 5) set to a lower priority than the first thread with no preemption threshold and no time slice.
  • Have all threads use the same entry point which contains no blocking function calls.

When I run this, I expect to see output from every thread as there are 4 cores to work with so while the high priority thread is executing on one core, the lower priority threads still have open hardware they can run on. Instead, I am only seeing the higher priority thread running as if it was blocking the other threads. Curiously, if I disable the preemption threshold on the higher priority thread, every thread runs as expected.

My question is, why does having a preemption threshold block lower priority threads from running, even when there is open hardware to run on? Is this behavior expected, or is there some sort of bug in the program? I have attached the main file I used to demonstrate this behavior (had to change the extension from .c to .txt to allow it to be uploaded). That file is the only one that I modified with the rest of the port staying the same as what I received.

sample_threadx.txt

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

2 answers

Sort by: Most helpful
  1. QuantumCache 20,266 Reputation points
    2023-03-09T19:18:34.3266667+00:00

    Hey @Collin

    Sorry that Scott is not available at this time! I am trying my best to help on this issue!

    Meanwhile, you can try adjusting the preemption threshold of the high priority thread to a lower value, or use priority inheritance to prevent priority inversion.

    Priority inheritance is a mechanism in ThreadX that automatically boosts the priority of a lower priority thread to the priority of the highest priority thread waiting for a shared resource, preventing priority inversion and ensuring timely execution of critical threads.

    I would suggest reviewing the documentation on preemption threshold and priority inheritance in Azure RTOS ThreadX to better understand the behavior and to determine the best approach for your specific application.

    Advanced technology

    Azure RTOS_Preemption-Threshold Scheduling

    0 comments No comments

  2. Scott Azure RTOS 4,051 Reputation points
    2023-04-04T18:27:28.02+00:00

    Hi Collin,

    Thanks for the detailed description!
    The lower preemption threshold should not have any effect on the other threads running. I see the mutex put/get functions have been commented out. Did you see the same behavior when the mutex get/put were in place? Are you able to halt the processor and see what each core is executing?

    0 comments No comments

Your answer

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