I have a region of code I want to prevent MQX from context switching. I can't disable interrupts, and I need to be able to insert messages in to queues that have waiting task with higher priority.
Is the only option to raise the priority of the current task while it performs a few message en-queues?
_task_stop_preemption does not work because it is only effective of preventing the scheduling when the slice time of the task has expired.
Hi Leif,
in MQX Reference Manual you can see this about _task_stop_preemption... "This includes the context switch at the end of a time-slice".
On one side, this sentence does not mean that it is effective until time-slice expires... It is just making explicit that even once time slice expires context switch will not occur.
On the other hand, if you use FIFO scheduling you don't need to care about time-slice.
Please note that setting a time-slice parameter in task template struct will cause the scheduling to behave as Round-Robin, however leaving this parameter blank or setting it to 0 will cause scheduler to behave as FIFO.
If you have any question please let me know.
Best regards,
Carlos
Thanks,
I understand _task_stop_preemption, and it does not prevent a context switch if the scheduler is called via a MQX function.
So my question still stands,
"Is the only option to raise the priority of the current task while it performs a few message en-queues?"
Hi Leif,
You are right, if you call explicitly the scheduler from the task then it will cause a context switch. In this specific case the only way you can prevent it is raising priority.
Regards,
Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------