Task Priorities - dealing with two cores

coratron
Posts: 4
Joined: Mon Dec 07, 2020 3:42 am

Task Priorities - dealing with two cores

Postby coratron » Mon Dec 07, 2020 4:15 am

Hi all,

I have been facing some issues and finally cornered the final suspects. I would like to hear from people that have some experience running RTOS across the two cores.

Description:
1) I have all my tasks in core1 except for one single task in core0 [we will call it networkTask()]
2) Priorities of tasks on core1 vary from 24 down to 16
3) Priority of the single task on core0 is the subject of this analysis.

Assumptions:
a) Task priorities are only relevant within the core their are running on.
b) Serial.print** functions can be run on two cores without issues.

Observations:
I) Assumption a) seems incorrect. Changing the priority of networkTask() to 1 (same as loop() ) changes the operation of the program, I can see that from the Serial.print outputs on the terminal.
II) Assumption b) seems incorrect as well. It all seems to be related to the mutex used behind the scenes for UART functions.
III) Tasks in core1 seemed to be blocked by networkTask() when its priority is set to something higher than 1, as loop() takes control of the UART with higher priority and the underlying mutex seems to be used. Not sure how tasks other than loop() are affected. I thought they would be totally decoupled.
IV) It would have been nice to see some sort of log on the terminal regarding UART mutex usage (I have log level set to 5). Flying completely blind until I discovered what was happening in the background.

Apparent Solution:
Increase default task priority of loop() from 1 to 2. Set priority of networkTask() to 1. I am not sure this is optimal but seems to work much better.

Any input on the topic is welcome!
Thanks

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: Task Priorities - dealing with two cores

Postby chegewara » Mon Dec 07, 2020 7:36 pm

From your description i think this may be the case:
https://www.freertos.org/FreeRTOS_Suppo ... 44d1j.html

coratron
Posts: 4
Joined: Mon Dec 07, 2020 3:42 am

Re: Task Priorities - dealing with two cores

Postby coratron » Wed Dec 09, 2020 5:56 am

chegewara wrote: From your description i think this may be the case:
https://www.freertos.org/FreeRTOS_Suppo ... 44d1j.html
@chegewara thanks for your reply. So do you mean the priorities are just being shifted when calling "Serial" functions from different tasks (and that having them on separate cores has nothing to do with priorities)?

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: Task Priorities - dealing with two cores

Postby chegewara » Thu Dec 17, 2020 1:49 am

I dont think it is related to Serial, but if you are using mutexes in your code it may be the case.

Who is online

Users browsing this forum: No registered users and 74 guests