Context switching in cooperative mode

Hello, Do calls to cQueueSend, cQueueReceive cause a context switch when FreeRTOS is running in cooperative mode, or is an explicit call to vPortYield() in the task code required to do this. The reason I ask is because calls to taskYIELD() appear in the cQueueSend(), cQueueReceive()  functions, but I don’t know if these will be called when in cooperative mode. Thanks Khusro

Context switching in cooperative mode

Calling these functions will implicitly call Yield, as you say.  A switch will occur if the call unblocks a task that has higher priority than the calling task. You could modify the code to prevent this if you wanted – I think you would need to ensure that the function xTaskResumeAll() in tasks.c (or cTaskResumeAll() depending on your version) always returns false if the cooperative scheme was being used.  Also remove the yield from within the xTaskResumeAll  function itself. To test for the cooperative scheme you can use #if configUSE_PREEMPTION == 1 Or you could design the tasks and priorities such that a yield will have no effect. The cooperative scheme just prevents the tick causing a switch.  The application then has control by either calling yield or an api function that will cause a yield. Hope this helps.