This commit removes the v10.4.3 kernel files in prepartion for upgrading to
v10.5.1.
- Portable files still remain
- Added as a separate commit to preserve commit history
This commit moves/merges the IDF FreeRTOS "PinnedToCore" task creation
functions from tasks.c/task.h to idf_additions.h/freertos_task_c_additions.h.
Also updated FreeRTOS Mock component to provide mocks for "idf_additions.h"
headers for our mock tests.
A weak xTimerCreateTimerTask() was added to tasks.c as a workaround in ESP-IDF
in order to prevent timers.c from being linked when unused.
This commit moves that workaround to `freertos_tasks_c_additions.h`
The following application hook protoypes are defined in task.h from FreeRTOS
V10.4.0 onwwards and no longer need to be declared in tasks.c, thus have been
removed:
- vApplicationStackOverflowHook()
- vApplicationTickHook()
- vApplicationGetIdleTaskMemory()
This function moves ulTaskNotifyTake()/xTaskNotifyWait() from IDF FreeRTOS
`tasks.c` to `freertos_compatibility.c`. These functions were kept for
pre-compiled library compatibilty. Move them reduces the kernel source code
difference when compared to upstream FreeRTOS.
This commit combines various task utility API additions in IDF FreeRTOS and with
their Amazon SMP FreeRTOS addition counterparts. The folloiwng functions have
been moved to freertos_tasks_c_additions.h and idf_additions.h as these API
are considered public:
- xTaskGetCurrentTaskHandleForCPU()
- xTaskGetIdleTaskHandleForCPU()
- xTaskGetAffinity()
- pxTaskGetStackStart()
Also fixed in missing #if macros when vTaskCoreAffinityGet() is called in
Amazon SMP FreerTOS tests.
This commit moves xTaskIncrementTickOtherCores() to freertos_tasks_c_additions.h
and freertos_idf_additions_priv.h (as API is private). This reduces the code
differences cmpared to upstream FreeRTOS.
- The following IDF API additions are moved to freertos_tasks_c_additions.h
(implementation) and freertos_idf_additions_priv.h (declaration) as APIs are
private. This reduces the source code difference from upstream.
- prvENTER_CRITICAL_OR_SUSPEND_ALL()
- prvEXIT_CRITICAL_OR_RESUME_ALL()
- prvENTER_CRITICAL_OR_MASK_ISR()
- prvEXIT_CRITICAL_OR_UNMASK_ISR()
- vTaskTakeKernelLock()
- vTaskReleaseKernelLock()
- Rename vTask[Take/Release]KernelLock() to prv[Take/Release]KernelLock() to
indicate that the this API is private.
Previously, TLSP deletion callbacks were...
- Stored in a seprate TCB member "pvThreadLocalStoragePointersDelCallback"
- Called separately via multipole prvDeleteTLS() insertions in tasks.c
This commit refactors how TLSP deletion callbacks are stored and called:
- TLSP deletion callbacks are now stored in "pvThreadLocalStoragePointers"
directly. configNUM_THREAD_LOCAL_STORAGE_POINTERS is doubled in size so that
the deletion callbacks are stored in the latter half of the array
- The callbacks are now called via "portCLEAN_UP_TCB()". As such, the
prvDeleteTLS() additions are no longer needed and the function can be removed
- Removed some legacy TLSP tests using the old method of storing the callback
pointers.
This commit reduces the source code diff between IDF FreeRTOS and upstream
vanilla FreeRTOS, in preparation for v10.5.1 upgrade.
portCLEAN_UP_COPROC() was an IDF specific addition to FreeRTOS, where the
macro was called from prvDeleteTCB() to clean up the coprocessor context of a
deleted task.
This commit removes portCLEAN_UP_COPROC(). The coprocessor cleanup routine
(i.e., vPortCleanUpCoprocArea()) is now called via portCLEAN_UP_TCB()->
vPortTCBPreDeleteHook().
This removes a minor code difference between IDF FreeRTOS and upstream.
This commit optimizes xTaskRemoveFromEventList() by removing the
listLIST_IS_EMPTY() check from single core builds. The scenario of the event
list being empty when the function is called can only occur on multi-core
builds.
This commit fixes and optimizes vTaskRemoveFromUnorderedEventList() in the
following ways:
- Fixed bug in single core builds where the unblocked task would be placed on
xPendingReadyList.
- If an ISR occurs while accessing xPendingReadyList, and the ISR also
accesses the xPendingReadyList, xPendingReadyList would be corrupted.
- In single core builds, this function is only called from event groups with
the scheduler suspended. Thus the function should have exclusive access to
pxReadyTasksLists instead of xPendingReadyList.
- The function's single core logic has now been updated to match upstream
behavior, by always placing the unblocked task on pxReadyTasksLists.
- Optimized the function for single core builds by removing the
taskCAN_BE_SCHEDULED() check.
- In single core builds, given that the function is always called with the
scheduler suspended
- Thus, the taskCAN_BE_SCHEDULED (and the subsequent routine to place the
unblocked task on the xPendingReadyList) is not necessary for single core
builds.
- The function now matches upstream behavior in single core builds.
Closes https://github.com/espressif/esp-idf/issues/11883
freertos: Updated vTaskRemoveFromUnorderedEventList() to consider scheduler state before adding task to ready list
Closes IDF-5785
See merge request espressif/esp-idf!23482
vTaskRemoveFromUnorderedEventList() runs under the assumption that the
scheduler is suspended during the call. However, for IDF FreeRTOS, this
is not true. When dual-core system is active, this API call is made in
a critical section but without suspending the scheduler. This commit
updates the vTaskRemoveFromUnorderedEventList() function to now consider
the scheduler state on either cores before adding a task to the ready list.
This commit fixes a bug in xTaskRemoveFromEvenetList() where in the
check for scheduler suspension did not account for nested suspensions.
Additionally, this commit updates all checks for scheduler
suspension to follow a uniform way.
FromISR APIs would put an unblocked task on the pending ready list if
the scheduler is suspended on the current core, irrespective of the
task's core affinity and the state of the scheduler on the other core.
This commit updates this behavior by allowing tasks to get scheduled on
a core which has the scheduler running as long as the task's core
affinity allows it.
This commit adds a common macro for the differing configASSERT() calls that
check if the scheduler is suspended outside a critical section. This macro
allows vanilla behavior to be restored for single core builds. Also added
comments explaining why xTaskGetSchedulerState() is called instead when
building for SMP.
Vanilla FreeRTOS expects applications to use one of the heap implementations
provided by FreeRTOS (i.e., heap_x.c), where functions such as pvPortMalloc()
and vPortFree() are defined in the heap implementation.
However, ESP-IDF already provides its own heap implementation
(i.e., esp_heap_caps.h). Thus, the pvPortMallc()/vPortFree() functions were
previously overriden by macro to call esp_heap functions directly.
This commit refactors the FreeRTOS port's heap as such:
- Added a heap_idf.c that implements all of the heap related functions required
by FreeRTOS source
- All dynamic memory allocated by FreeRTOS is from internal memory. Thus, the
FreeRTOS heap is the internal memory subset of the ESP-IDF heap.
- Removed some old macros to reduce diff from upstream source code.
Previously, IDF FreeRTOS would restrict the clean up of task memory (done by
vTaskDelete() or the Idle task) to only tasks pinned to the current core or
unpinned tasks. This was due to the need to clear the task's coprocessor
ownership on the other core (i.e., "_xt_coproc_owner_sa"). But this restriction
can be lifted by simply protecting access of "_xt_coproc_owner_sa" with a
spinlock.
This commit implements a "_xt_coproc_owner_sa_lock" to protect the access of
"_xt_coproc_owner_sa", thus vTaskDelete() and prvDeleteTCB() can now delete
tasks pinned to the other core so long as that task is not currently running.
Note: This fix was copied from the Xtensa port of Amazon SMP FreeRTOS
This commit removes the dependency on portUSING_MPU_WRAPPERS on the Xtensa port
of IDF FreeRTOS. This dependency was added due to a hack implemented in the
upstream port that required the usage of the "xMPUSettings" member of the TCB.
The "xMPUSettings" would be used as a pointer to the task's coprocessor save
area on the stack, even though FreeRTOS MPU support was not available.
The hack has now been removed, and the CPSA pointer is now calculated using
a combination of constant offsets values and the pxEndOfStack member of the
TCB.
Note: This impelemtation was copied from the Xtensa port of Amazon SMP FreeRTOS.
This commit restores the vanilla behavior for taskSELECT_HIGHEST_PRIORITY_TASK
when configNUM_CORES == 1 && configUSE_PORT_OPTIMISED_TASK_SELECTION == 0. This
results in the SMP selection algorithm (taskSelectHighestPriorityTaskSMP) to
only be run when configNUM_CORES > 1.
Due to SMP, critical sections have been added to xTaskIncrementTick() and
vTaskSwitchContext() (to take the xKernelLock). However, this is technically
not necessary when building for single-core as FreeRTOS expect these funcitons
to be called with interrupts already disabled.
This commit makes the critical secitons in those functions depend on
"configNUM_CORES > 1", and ensures that interrupts are disabled when calling
those functions. This effectively restores the vanilla behavior for these
functions when building for single-core.
In IDF FreeRTOS, when building for SMP, there are numerous functions
which require different critical sections when compared to single-core. This
commit encapsulates those difference into a common set of macros whose
behavior depends on "configNUM_CORES > 1". As such...
- Vanilla behavior has been restored for some functions when building for
single core (i.e., used to call taskENTER_CRITICAL, now disables interrupts
mactching vanilla behavior).
- Reduces number of "#ifdef (configNUM_CORES > 1)" in functions
- Any SMP only critical sections are now wrapped by
"#ifdef (configNUM_CORES > 1)" and properly documented via comments.
This commit updates how configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS is defined
by default it to 0 if not defined elsewhere. Dependent code now check for
"configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1" instead.
This commit synchronize the cosmetic differences of IDF FreeRTOS to upstream
Vanilla v10.4.3. Comsetic differences include:
- Out of date doxygen API descriptions
- Misnamed parameters
- Missing examples
- Fixed/added missing @cond/@code directives
- Extra/missing comments/lines
- Code formatting (uncrustify)
Other changes:
- Some ESP_PLATFORM directives were also removed
- xTaskIncrementTickOtherCores() now depends on "configNUM_CORES > 1"
- Updated some multi-core dummy variable names in FreeRTOS.h
The following changes have been made in this commit:
1. configMINIMAL_STACK_SIZE is now defined as CONFIG_FREERTOS_IDLE_TASK_STACKSIZE.
2. Removed configIDLE_TASK_STACK_SIZE config as it was redundant.
3. Updates the order of allocating the TCB and stack memory to avoid the
stack memory overriding the TCB memory when the stack grows downwards.
4. CONFIG_FREERTOS_IDLE_TASK_STACKSIZE is now incorporated into the
FreeRTOSConfig_smp.h to configure the IDLE0 stack size.
This commit synchronizes multiple functions in tasks.c with upstream v10.4.3
that contain minor differences.
The following functions have had their parameter names or code formatting
updated:
- xTaskCreateStaticPinnedToCore()
- xTaskCreatePinnedToCore()
- prvInitialiseNewTask()
- prvTaskIsTaskSuspended()
- vTaskStartScheduler()
- xTaskResumeAll()
- xTaskCheckForTimeOut()
- uxTaskResetEventItemValue()
The following functions have had their missing "xAlreadyYielded" restored
- xTaskDelayUntil()
- vTaskDelay()
The following functions have had their critical section/interrupt disdable
usage update
- vTaskSuspendAll()
- xTaskGetTickCountFromISR()
- xTaskGetApplicationTaskTagFromISR()
This commit synchronizes multiple functions that contain major differences with
upstream v10.4.3. Multi-core modifications are then reapplied to the function.
Vanilla code uses "pxTCB == pxCurrentTCB" to check whether a task is currently
running. This commit adds the following macros instead.
- taskIS_CURRENTLY_RUNNING()
- taskIS_CURRENTLY_RUNNING_ON_CORE()
The following functions have been updated to use those macros instead.
- eTaskGetState()
- vTaskPrioritySet()
- vTaskResume()
The following functions have been synchronized with upstream v10.4.3.
Multi-core modifications are then reapplied.
- vTaskSuspend()
- vTaskDelete()
- prvGetExpectedIdleTime()
This commit synchronizes multiple functions in tasks.c with upstream v10.4.3
that contain minor differences.
The following functions have had their parameter names or code formatting
updated:
- xTaskCreateStaticPinnedToCore()
- xTaskCreatePinnedToCore()
- prvInitialiseNewTask()
- prvTaskIsTaskSuspended()
- vTaskStartScheduler()
- xTaskResumeAll()
- xTaskCheckForTimeOut()
- uxTaskResetEventItemValue()
The following functions have had their missing "xAlreadyYielded" restored
- xTaskDelayUntil()
- vTaskDelay()
The following functions have had their critical section/interrupt disdable
usage update
- vTaskSuspendAll()
- xTaskGetTickCountFromISR()
- xTaskGetApplicationTaskTagFromISR()
This commit synchronizes multiple functions that contain major differences with
upstream v10.4.3. Multi-core modifications are then reapplied to the function.
Vanilla code uses "pxTCB == pxCurrentTCB" to check whether a task is currently
running. This commit adds the following macros instead.
- taskIS_CURRENTLY_RUNNING()
- taskIS_CURRENTLY_RUNNING_ON_CORE()
The following functions have been updated to use those macros instead.
- eTaskGetState()
- vTaskPrioritySet()
- vTaskResume()
The following functions have been synchronized with upstream v10.4.3.
Multi-core modifications are then reapplied.
- vTaskSuspend()
- vTaskDelete()
- prvGetExpectedIdleTime()
This commit synchronizes the following xTaskRemoveFrom...EventList() with
upstream v10.4.3. Multi-core modifications are then reapplied to the
functions.
The functions updated are:
- xTaskRemoveFromEventList()
- vTaskRemoveFromUnorderedEventList()
The following multi-core macros have been removed as they are no longer
required.
- tskCAN_RUN_HERE()
- taskYIELD_OTHER_CORE()
This commit synchronizes the following vTaskPlaceOnEventList...() with
upstream v10.4.3.
The functions updated are:
- vTaskPlaceOnEventList()
- vTaskPlaceOnUnorderedEventList()
- vTaskPlaceOnEventListRestricted()
The traceTASK_DELAY_UNTIL() macro has also been updated.
This commit reverts the previous "taskENTER_CRTIICAL();" so that the argument
is now provided for better code readability. The names of the spinlocks have
also been updated.
This commit updates various FreeRTOS functions to call the newly added
prvCheckForYield() and prvCheckForYieldUsingPriority() when checking for
yielding. This allows the source code to match upstream more closely.
When a FreeRTOS function unblocks a task, that function will check whether
the unblocked task requires a yield to be called. This is currently done by
having each function individually check if the unblocked task has a higher
priority than the both cores, and yielding the appropriate core.
This commit adds the macros list below to abstract away the yielding checking
procedure. This will allow the code to match upstream more closely.
- prvCheckForYield()
- prvCheckForYieldUsingPriority()
This commit fixes vTaskSuspendAll() and xTaskResumeAll() in the following ways.
- For vTaskSuspendAll()
- Sync function source code with upstream single core version
- Clearly mark IDF additions
- For xTaskResumeAll()
- Sync function source code with upstream single core version
- Clearly mark IDF additions
- Fix bug where cores other than core 0 were allowed to unwind pended ticks
This commit fixes the following issues:
- Clearly mark IDF additions in vTaskStepTick() and xTaskCatchUpTicks()
- Add back vTaskSuspendAll()/xTaskResumeAll() to xTaskCatchUpTicks(). Scheduler
suspension and resumption is required to unwind the pended ticks.