Disable Timer Interrupts until task decides to yield to scheduler on the Posix Port

I’ve been trying to find a way to disable interrupts (for all tasks given any priority) when a certain task is running.

Here’s what’s happening -

  1. The desired task runs within the critical section context (using vPortEnterCritical) but is preempted by the systick handler in the middle of execution.

  2. This causes some unwanted deadlocks further due to other threads waiting for this resource.

I’m running a small experiment on the posix blinky (modified to my requirements) and have added instrumentation to all the kernel functions (which also includes the idleTask). The systick preemption happens when my instrumented code is called from inside the idleTask. What can be a simple workaround for this?

In the posix port vPortEnableInterrupts works by masking all the pthread signals to the thread that called the function, hence the called thread is not interrupted by other signals from other tasks. It doesn’t block the systick timer thread from running.

So there’s no workaround for disabling timer interrupt until a required task finished executing?

Can you elaborate on what deadlocks are you seeing? As long as the tick does not cause context switch, you should be okay?