My FreeRTOS program has a TCP task which uses socket API. I want to use cooperative scheduler for the program, but my vendor-provided lwip port doesn’t work if configUSE_PREEMPTION is 0.
Does FreeRTOS-Plus-TCP support cooperative scheduling?
FreeRTOS+TCP isnt well tested with cooperative scheduling.
Is there something that prevents you from using the preemptive scheduler?
My application has many communication tasks that use various protocols to access all kinds of data (inputs, states of business tasks, parameters). I don’t know how to properly share data among tasks in a preemptive scheduler, apart from using a global mutex in every task (which would be effectively cooperative).
Is your application structure such that all tasks access all the data? If not, you can divide data into groups for more granular locking instead of a global mutex. Tasks operating on the global data can make a local copy and then use that - this will shorten the critical section and you can consider using taskENTER_CRITICAL/taskEXIT_CRITICAL instead of mutex.
Here is my 2 cents:
Suppose you have this priority scheme:
- Priority 3: The network interface (highest)
- Priority 2: The TCP/IP task
- Priority 1: Your task which uses TCP/IP
Suppose that preemption is disabled, then your task will be able to hold up the higher-priority tasks. Maybe it has to do a big FFT analysis, taking a few seconds. That would be fatal for TCP/IP operations.
So I don’t know if cooperative scheduling will work for you, for me it won’t. My lowest-priority-tasks have the freedom to sort out difficult things, without disturbing other tasks, without having to yield.
So “cooperative scheduling” is supported, but it demands that lower-priority tasks behave well, which means that they leave enough processing time for the IP-stack and other drivers.