In `prvCheckForRunStateChange()`, enabling interrupts should cause this core to immediately service the pending interrupt and yield. Upon the next scheduling of the task, the assertion `configASSERT(pxThisTCB->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD);` may not be true, as other cores could have requested a yield for this task before it evaluates its run state within the assertion. To address this, the task re-evaluates its run state in critical section within a loop until it is eligible for execution, which is the current implementation. Consequently, this assertion should be removed to ensure correct behavior.
* Add traceSTARTING_SCHEDULER tracing hook.
Discussed here: https://forums.freertos.org/t/tracing-improvements/20097
This hook enables tracers to run code on startup after all RTOS
resources are created and to detect that the scheduler is starting without
relying on traceENTER/traceEXIT macros.
It also provides tracers access to the task handle of all IDLE tasks,
allowing them to be identified unambiguously and without relying on
INCLUDE_xTaskGetIdleTaskHandle.
* Fix the constant suffix to U
* Fix more unsigned contant suffix
---------
Co-authored-by: Ubuntu <ubuntu@ip-172-31-34-245.ap-northeast-1.compute.internal>
* pxIndex should only be used when selecting next task. Altering pxIndex
of a ready list will cause the scheduler to be unable to select the
right task to run. Using a for loop if traversing the list for trace
utility is required.
* Not defining listGET_OWNER_OF_NEXT_ENTRY when using SMP scheduler
---------
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
* Update task notification scheduler suspension
Previously ulTaskGenericNotifyTake() and xTaskGenericNotifyWait() would suspend
the scheduler while inside a critical section.
This commit changes the order by wrapping the critical sections in a scheduler
suspension block. This logic is more inuitive and allows the SMP scheduler
suspension logic to be simplified.
* tasks.c: Fix typo
* Use a complete sentence in comment
* Check portGET_CRITICAL_NESTING_COUNT when scheduler is running
* Prevent potential NULL pointer access when scheduler is not running
---------
Co-authored-by: Paul Bartell <pbartell@amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Ching-Hsin Lee <chinglee@amazon.com>
* Request a task to yield after been suspended or deleted to prevent this task puts itself back to another list
* Fix volatile variable access order to ensure ensure compliance with MISRA C 2012 Rule 13.5
---------
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Enable xTaskGetCurrentTaskHandleForCore() for single core builds
---------
Co-authored-by: Paul Bartell <pbartell@amazon.com>
Co-authored-by: Ching-Hsin Lee <chinglee@amazon.com>
* Update vTaskDelete() to delete a task directly when scheduler is stopped instead of putting it on the xTasksWaitingTermination list.
* Delete the idle tasks and timer task in vTaskEndScheduler().
* Reclaim resources for all the tasks on the xTasksWaitingTermination list in vTaskEndScheduler().
* Update POSIX to no longer delete FreeRTOS tasks in the port.
---------
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
* Error when configSUPPORT_STATIC_ALLOCATION is set for MPU ports
* Uncrustify: triggered by comment.
---------
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
This commit adds a portTASK_SWITCH_HOOK() macro which allows ports to inject
behavior immediately after a context switch. For example, this macro could be
used by ports that need to set an end of stack watchpoint after a context
swtich.
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Tony Josi <tonyjosi@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
* Assign return value of xPortStartScheduler API to a variable
* Add void datatype
---------
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
* Update xTaskGetIdleTaskHandle() in SMP
This commit updates xTaskGetIdleTaskHandle() for SMP in the following ways:
- xTaskGetIdleTaskHandle() no longer accepts xCoreID argument in SMP so that
there is not change in API between single-core and SMP
- xTaskGetIdleTaskHandle() now returns the Active idle task handle in SMP,
which matches the behavior in single-core.
- Added xTaskGetIdleTaskHandleForCore() in SMP which accepts an xCoreID
argument. This function can be used to obtain the Passive idle task handles.
* Update xTaskGetIdleTaskHandle
---------
Co-authored-by: Ching-Hsin Lee <chinglee@amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
* The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category.
---------
Co-authored-by: Ubuntu <ubuntu@ip-172-31-34-245.ap-northeast-1.compute.internal>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
* Update vApplicationGetIdleTaskMemory prototype for SMP. Now SMP and
single core use the same prototype for compatibility.
* Add vApplicationGetPassiveIdleTaskMemory for SMP to get passive idle
task memory.
* Fix prvTaskIsTaskSuspended.
Just like eTaskGetState, distinguish waiting for notify from suspend.
* Fix vTaskGetInfo.
Just like eTaskGetState, distinguish block state (waiting on notification)
from suspend state.
* Add missing definition of variable x.
* Fix formatting syntax.
---------
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Tony Josi <tonyjosi@amazon.com>
The function vTaskSwitchContext in smp has an parameter of core id,
which means this function is not only used for the core who call it.
Thus we should use the task running on the specific core id,
instead of use the task running on the core who call this function.
Co-authored-by: moral-hao <405197809@qq.com>
This commit renames "CPU" to "Core" for any public facing API for consistency
with other SMP related APIs (e.g., "configNUMBER_OF_CORES").
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>