I am quite new to ESP32, coming from PIC32 MCUs which are all single core. So I would like to check if I'm right when it comes to running FreeRTOS scheduler on two cores. It seems to me that if a task is pinned to one core, than this task could be skipped by scheduler in round robin scheme (same priority tasks run in turn triggered by ticks) since both cores are using the same pointer to a task list of that specific priority, but looking only for tasks with no affinity or pinned to that specific core. So when one core skips the task pinned to the other core, it moves the pointer forward and the other core will continue traversing the task list from that point on, which means the skipped task won't be run.
If I'm right, then it seems a better strategy would be to create all application tasks with no cpu affinity. By doing that, all tasks can be run by both cores which guarantees no task would be ever skipped like in the above scenario.
I would appreciate a comment from someone with more experience in this matter.
Using RTOS tasks with or without cpu core affinity
-
- Posts: 9759
- Joined: Thu Nov 26, 2015 4:08 am
Re: Using RTOS tasks with or without cpu core affinity
You actually are right, and this is explained in the documentation: http://esp-idf.readthedocs.io/en/latest ... scheduling
You could indeed get around this by un-pinning all tasks. As an alternative, if you have multiple tasks of the exact same priority pinned to both cores, I'd suggest moving the tasks on one core to a level higher or lower; that solves the problem without the need to un-pin tasks.
You could indeed get around this by un-pinning all tasks. As an alternative, if you have multiple tasks of the exact same priority pinned to both cores, I'd suggest moving the tasks on one core to a level higher or lower; that solves the problem without the need to un-pin tasks.
Re: Using RTOS tasks with or without cpu core affinity
Yes, you could just use a specific set of priority levels for each core, not mixing them together and that solves the problem. This then leads to the next question - are the API tasks pinned to a specific core, which one (I guess the PRO core) and what priority levels do they use?
-
- Posts: 9759
- Joined: Thu Nov 26, 2015 4:08 am
Re: Using RTOS tasks with or without cpu core affinity
From memory, most tasks are either pinned to core 0 (WiFi, BT) or unpinned (lwip).
Re: Using RTOS tasks with or without cpu core affinity
System tasks priority list (all but acceptTask and HttpServerTask are system tasks):
- Attachments
-
- ble.jpg (65.78 KiB) Viewed 9715 times
Re: Using RTOS tasks with or without cpu core affinity
Keep in mind that if an unpinned task executes a single-precision floating point (`float`) operation, it will be automatically pinned to the core that happens to be executing that task at that time.
Who is online
Users browsing this forum: No registered users and 150 guests