-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xTaskCreate ignore the priority. #3093
Comments
I would rather say its problem with codeID identification rather than ignoring task priority. You can easy test it by increasing number of tasks:
|
Task1 switches to core 0 but you only call xPortGetCoreID once |
I changed my code.
Task1 start with core1 and end with core1.
Task1 switches to core 0 ?? |
What is problem with codeID identification ?? |
This is what i mean:
By default when you create 2 tasks with xTaskCreate then most likely both tasks will start on both cores, but your tasks are on the same core (core1). In the other hand, logs suggest that both tasks are running on different cores, because both start and end on the same time, are running simultaneously (compare with my logs). When you have 2 tasks running on the same core, with code you provisioned in OP, and you modify code the way i asked you then you will be sure that at least 2 tasks will be running on the same core. Here are logs:
Those logs suggest that you are right about ignoring priority, but not exactly. The problem is specific of
Conclusion: PS as you can see all 3 tasks in my last logs also are running on |
My observations:
Compare logs:
|
Yeah something is sketchy...
|
I changed my tick rate from 100Hz to 1000Hz.
|
I tried your code.
|
43947 = core 1, 52685 = core 0 |
I would suggest to rename topic and ask @projectgus or @igrr for help. |
Thank you for your help. |
I experienced it more strangely.
Case 1
Case 2
|
I dont know how to explain this more clearly. This code is occupying all core time and 3rd task (3rd xCreateTask) wont be called as long as it is running:
If you replace it with |
I know that If i replace it with But i can't understand why task3 that have priority 3 start after task2 that have priority 2. At 249 Tick time, CoreID 1 is empty. |
Please try this:
Its not true. Look at logs:
Task2 is running on core 0 and Task1 is running on core 1. Both cores are occupied. |
I understood a reason.
My conclusion Thank you. |
A few things to note
|
@Dazza0 it sounds reasonable, but what about those logs:
As we can see Task1 and Task2 are running simultaneously on different cores but
|
That is really weird, even with delay and increased priority both tasks switch cores exactly in between the calls to get the core id resulting in a mismatch?
Edit: even when inside a critical section they don't match. |
Perhaps @negativekelvin can you please post the exact source you are compiling for this test? |
code
|
@negativekelvin I'm not be able recreate your issue, but looking at the assembly code of Assembly when xPortGetCoreID() is NOT volatile
Notice how at the first critical section (from Assembly when xPortGetCoreID() IS volatile
|
Ok so will you add volatile keyword to xPortGetCoreID? |
@negativekelvin yes |
When xPortGetCoreID() is called twice within a function, it might only be called once after compilation. This commit makes the inline assembly of the function volatile. Closes #3093
When xPortGetCoreID() is called twice within a function, it might only be called once after compilation. This commit makes the inline assembly of the function volatile. Closes #3093
When xPortGetCoreID() is called twice within a function, it might only be called once after compilation. This commit makes the inline assembly of the function volatile. Closes #3093
I tested this code.
When i use xTaskCreate, It work round-robin.
The priority is ignored.
When i use xTaskCreatePinnedToCore, It work follow the priority.
The text was updated successfully, but these errors were encountered: