Fixed buffer underflow in prvSelectHighestPriorityTask.#607
Fixed buffer underflow in prvSelectHighestPriorityTask.#607tobireinhard wants to merge 2 commits intoFreeRTOS:smpfrom
prvSelectHighestPriorityTask.#607Conversation
|
Thanks for submitting this, we'll take a look |
|
Our CI is a little bit of a pain right now. I'm going to push a commit to your change to update this line. This should stop the header check from failing. Essentially Python 3.7.10 isn't available on Ubuntu 20.04 anymore. This won't have any impact on the functionality of your PR and is purely to fix the CI. |
Python 3.7.10 is no longer supported. Python 3.11.0 is preferred.
| if(uxTopReadyPriority > 0) { | ||
| uxTopReadyPriority--; | ||
| } |
There was a problem hiding this comment.
Nit pick, non-blocking: I realize 0 isn't exactly a magic number in this context BUT I would prefer this line to say uxTopReadyPriority > tskIDLE_PRIORITY. This would read like "The Top Ready Priority cannot be less than the idle task" rather than "The Top Ready Priority cannot be less than 0". While these are functionally the same, pinning this to the idle task would make it clearer that no task can be lower in priority than the idle task.
| if(uxTopReadyPriority > 0) { | ||
| uxTopReadyPriority--; | ||
| } |
There was a problem hiding this comment.
The formatting should be something like the following (to adhere to the Kernel's formatting style)
| if(uxTopReadyPriority > 0) { | |
| uxTopReadyPriority--; | |
| } | |
| /* The top ready priority cannot be less than the idle task's priority. */ | |
| if( uxTopReadyPriority > tskIDLE_PRIORITY ) | |
| { | |
| uxTopReadyPriority--; | |
| } |
AniruddhaKanhere
left a comment
There was a problem hiding this comment.
Hello @tobireinhard,
Just a couple of comments regarding formatting (also included the suggestion by @kstribrnAmzn). If they seem correct to you, would you mind pushing them?
Thanks,
Aniruddha
| if(uxCurrentPriority > 0) { | ||
| uxCurrentPriority--; | ||
| } |
There was a problem hiding this comment.
Similarly here as well
| if(uxCurrentPriority > 0) { | |
| uxCurrentPriority--; | |
| } | |
| /* The top ready priority cannot be less than the idle task's priority. */ | |
| if( uxCurrentPriority > tskIDLE_PRIORITY ) | |
| { | |
| uxCurrentPriority--; | |
| } |
I would like to share some observation about this problem. Suggest we consider to update the vTaskSuspend function and ensure that prvSelectHighestPriorityTask won't be called before scheduler started in another PR. |
|
Closing this PR as it is no longer needed after #610. |
Add a hardware definition project for the MicroZed board to the existing Zynq ZC702 project. Add a text file that describes how to switch the Zynq project form the ZC702 hardware to the MicroZed hardware.
Fixed buffer underflow in
prvSelectHighestPriorityTask.Description
The function
prvSelectHighestPriorityTaskis called fromvTaskSwitchContextwhenever the scheduler selects a new task to run. It can also be called fromvTaskSuspendbefore the scheduler is running and before the idle tasks have been created.In the latter case, the global variable
uxTopReadyPriorityis decreased to -1. During the next regular context switch,prvSelectHighestPriorityTasktries to access the global ready list arraypxReadyTasksLists[ uxCurrentPriority ]. This causes a memory error.Test Steps
Initialize the ready lists stored in
pxReadyTasksListsto be empty and callprvSelectHighestPriorityTask. Check that after the the function terminates, the global variableuxTopReadyPriorityhas value -1. CallvTaskSwitchContextand check that it causes a buffer underflow.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.