vTaskSuspendAll, xTaskResumeAll and configUSE_PREEMPTION = 0
Hi everybody, for one of my project I use Cooperative Multi-threading (configUSE_PREEMPTION = 0)
And think that vTaskSuspendAll and xTaskResumeAll are useless in this case
Since xTaskResumeAll may cause YIELD and I use heap_3 Malloc scheme
vTaskSuspendAll, xTaskResumeAll and configUSE_PREEMPTION = 0
Initial thought is to keep them, but to just not yield if configUSE_PREEMPTION is 0, but second thought is you might be right to just compile them out all together.
When the RTOS is suspended interrupts can happen but context switches cant, but if you are using cooperative scheduling then context switches are not going to happen anyway.
But even when configUSE_PREEMPTION is 0 a context switch can happen if you for example send to a queue and there is a task blocked on the queue – but that is more expected behavior whereas calling resumeAll and getting a context switch isnt.
vTaskSuspendAll, xTaskResumeAll and configUSE_PREEMPTION = 0
hm, yes vTaskSuspendAll can be used in cooperative sheduller to avoid
context switch in QueueSend or SemaphoreGive, so vTaskSuspendAll can’t be empty.
But context switch in pvPortMalloc not expected (for me)
vTaskSuspendAll, xTaskResumeAll and configUSE_PREEMPTION = 0
Take a look at the head revision in SVN – the co-operative behaviour has been changed, and as such it will probably be released as V7.6.0.
Now a context switch is only performed if the calling task is blocked. For example, if you attempt to write to a queue with a block time specified and the queue is full then the task will block and another task will start running. However, if you successfully write to the queue, and writing to the queue causes a task of higher priority to unblock, then a context switch will not occur – the original task will continue executing until it either blocks or calls taskYIELD().
Likewise when changing the priority of another task, or unsuspending another task, etc. A context switch will not occur even if the API call makes a higher priority task ready to run.
Regards.