Commit Graph

133 Commits (14903c380ea276f2766a5a096353da285831b2b8)

Author SHA1 Message Date
chinglee-iot 94cb87ad30
Assign idle task to each core before SMP scheduler start (#945)
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
1 year ago
Soren Ptak 553b0ad5d3
Update comments related to portYIELD_FROM_ISR() in queue.h #925 1 year ago
Darian bd0f87c18b
Add portTASK_SWITCH_HOOK (#867)
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>
1 year ago
chinglee-iot a79752a04a
Remove lint suppression comment (#920)
Remove lint suppression comment
1 year ago
chinglee-iot d95b05ea5f
Suppress MISRA C:2012 rule 21.6 for snprintf (#877)
Suppress MISRA C:2012 rule 21.6 for snprintf
1 year ago
Rahul Kar 93ef558fa8
Declare variable without initializer (#841)
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
Rahul Kar 55094e2ddf
Fix MISRA_C_2012 rule 13.2 violation (#855)
* Assign volatile variables to local non-volatile variables before read

* Fix stack macro overflow check volatile access

* Explicit the read order of volatile variable

* Fix issue : ISO C90 forbids mixed declarations and code



---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-34-245.ap-northeast-1.compute.internal>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Monika Singh <moninom@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
Rahul Kar d1a0202125
Fix MISRA_C_2012 rule 8.4 violation (#844)
Fix MISRA_C_2012 rule 8.4 violation
1 year ago
Rahul Kar 71d86f9a6e
Fix MISRA_C_2012 rule 17.7 violation (#848)
* 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>
1 year ago
Rahul Kar edce1e94b3
Fix MISRA_C_2012 rule 20.7 violation (#843)
* Wrap macro parameter expansion by parentheses
* Update parentheses in SMP macro definition

---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Monika Singh <moninom@amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
chinglee-iot 84c0047ccd
Suppress MISRA C:2012 rule 11.5 deviations (#878)
* Suppress MISRA C:2012 rule 11.5 deviations by comment also remove this rule in global config

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-34-245.ap-northeast-1.compute.internal>
Co-authored-by: Rahul Kar <karahulx@amazon.com>
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
Darian cd5c774b2b
Update xTaskGetIdleTaskHandle() For SMP (#868)
* 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>
1 year ago
chinglee-iot dabbc05a39
Suppress MISRA C rule 11.3 in MISRA.md (#857)
Suppress MISRA C rule 11.3 in MISRA.md
1 year ago
chinglee-iot 1813a4551e
Fix MISRA 2012 rule 10.4 violations (#852)
Fix MISRA 2012 rule 10.4 violations
1 year ago
chinglee-iot ce88adea2a
Fix MISRA C 2012 Rule 10.3 errors (#860)
* 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>
1 year ago
chinglee-iot ac4313560f
Not to use object modified in the loop body (#861)
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>
1 year ago
Moral-Hao 5f2bb1b48b
In smp, every core has a idle task. (#893)
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
chinglee-iot dc09a3dd51
Add vApplicationGetPassiveIdleTaskMemory for SMP (#890)
* 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.
1 year ago
Moral-Hao 0640b2e486
Distinguish waiting for notify status from suspend status (#865)
* 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>
1 year ago
Moral-Hao 8ede50cafd
Fix vTaskSwitchContext for smp. (#879)
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>
1 year ago
Darian 4ef0bb676c
vTaskListTasks prints core affinity mask (#850)
This commit updates vTaskListTasks so that it prints uxCoreAffinityMask if
core affinity is enabled in configuration.
1 year ago
Darian fc7aca7ff2
Rename CPU to Core (#849)
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>
1 year ago
Rahul Kar 30283b57df
Fix xTaskNotifyWait & ulTaskNotifyTake determinism. (#833)
This PR fixes the bug described in the following issue:
https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/612.
This was originally contributed in the following PR:
https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/625.

The implementation suspends the scheduler before exiting the
critical section (i.e. before enabling interrupts). If we do not do
so, a notification sent from an ISR, which happens after exiting
the critical section and before suspending the scheduler, will
get lost. The sequence of events will be:

1. Exit critical section.
2. Interrupt - ISR calls xTaskNotifyFromISR which adds the task to
    the Ready list.
3. Suspend scheduler.
4. prvAddCurrentTaskToDelayedList moves the task to the delayed
    or suspended list.
5. Resume scheduler does not touch the task (because it is not on
    the pendingReady list), effectively losing the notification from
    the ISR.

The same does not happen when we suspend the scheduler before
exiting the critical section. The sequence of events in this case will
be:

1. Suspend scheduler.
2. Exit critical section.
3. Interrupt - ISR calls xTaskNotifyFromISR which adds the task to
    the pendingReady list as the scheduler is suspended.
4. prvAddCurrentTaskToDelayedList adds the task to delayed or
    suspended list. Note that this operation does not nullify the add
    to pendingReady list done in the above step because a different
    list item, namely xEventListItem, is used for adding the task to the
    pendingReady list. In other words, the task still remains on the
    pendingReady list.
5. Resume scheduler moves the task from pendingReady list to the Ready list.

------------

Co-authored-by: Jacob Carver <karver8@github.com>
1 year ago
chinglee-iot 7ffc6a7465
Add base priority get APIs (#818)
* Add base priority get APIs
* Add MPU changes

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
chinglee-iot 2be332ae21
Separate the task create function for core affinity (#789)
* Separate the task create function for core affinity
* Update function prototype and comment
* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
chinglee-iot 4bfb9b2d70
Update SMP get idle task memory for static allocation (#784)
* Add static idle task memory support for SMP
* Rename vApplicationMinimalIdleTask to vApplicationPassiveIdleTask
* Rename the macro configUSE_MINIMAL_IDLE_HOOK to configUSE_PASSIVE_IDLE_HOOK
* Update xTaskGetIdleTaskHandle for SMP
* Add more check in xTaskGetIdleTaskHandle
* Support configKERNEL_PROVIDED_STATIC_MEMORY for SMP

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
chinglee-iot d442d7908a
Add configCONTROL_INFINITE_LOOP for loop control in unit test (#783)
* Add configCONTROL_INFINITE_LOOP in FreeRTOS.h
* Use configCONTROL_INFINITE_LOOP in tasks.c and timer.c

---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
1 year ago
chinglee-iot 97d48ba94a
Add more comment for core affinity in prvSelectHighestPriorityTask (#801)
* Add more comment for core affinity in prvSelectHighestPriorityTask

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 year ago
chinglee-iot 317bc0c89c
Move trace macro after declaration (#820)
* Move trace macro after declaration to comply with ISO C90
1 year ago
chinglee-iot 30e13dac2b
Implement prvYieldCore with macro (#785)
* Implement prvYieldCore with macro for performance and memory
* Remove the portCHECK_IF_IN_ISR macro check. It is not required in SMP
  now

Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
chinglee-iot 830533d49e
Add taskYIELD_WITHIN_API macro (#782)
Add taskYIELD_WITHIN_API macro for readability improvement.
1 year ago
Gaurav-Aggarwal-AWS 96d6190b61
Replace sprintf with snprintf (#802)
This change necessitates the introduction of 2 new APIs:

void vTaskListTasks( char * pcWriteBuffer, size_t uxBufferLength );
void vTaskGetRunTimeStatistics( char * pcWriteBuffer, size_t uxBufferLength );

These 2 APIs behave exactly as vTaskList and vTaskGetRunTimeStats
except the fact that they take the length of the pcWriteBuffer as the
second argument to ensure that we do not write past the buffer.

vTaskList and vTaskGetRunTimeStats assume that the length of the
buffer is configSTATS_BUFFER_MAX_LENGTH which defaults to 0xFFFF.
This is done to ensure that the existing applications do not break.
New applications should use the new APIs to avoid memory corruption.
1 year ago
chinglee-iot 2bc6188be3
Update pxMutexHolder is NULL check description (#800) 1 year ago
Sebastian Brosch 83861f5b1d
Add Trace Hook Macros to all API calls (#786)
This pull-request adds out-of-the-box support for different tracing
tools. New trace hook macros have been added for all public API
functions, one for each function entry and one for each exit. There are
no functional changes, as the macros are by default empty.

For more information see following forum post:
https://forums.freertos.org/t/add-tracing-functionality-for-all-api-calls/18007.
1 year ago
Mehdi 7cd201c290
Add default implementations of vApplicationGetIdleTaskMemory and vApplicationGetTimerTaskMemory (#790)
This PR introduces configKERNEL_PROVIDED_STATIC_MEMORY option
which the application can set to 1 to use the default implementations
of vApplicationGetIdleTaskMemory and vApplicationGetTimerTaskMemory
functions.

If the application enables static allocation (i.e. sets
configUSE_STATIC_ALLOCATION to 1) and does not provide the above 2
functions, it will result in linker error. The application has two options:

1. Set configKERNEL_PROVIDED_STATIC_MEMORY to 1 to use the default
    implementations of these functions.
2. Provide implementations of these 2 functions.

Note that default definitions are only available for non-MPU ports. The
reason is that the stack alignment requirements vary for different
architectures.
1 year ago
chinglee-iot 7db0e87af1
Update taskYIELD_IF_USING_PREEMPTION macro (#769)
* Add taskYIELD_TASK_CORE_IF_USING_PREEMPTION and taskYIELD_ANY_CORE_IF_USING_PREEMPTION to align task yield behavior for single core and SMP.
---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
1 year ago
Boris van der Meer 2f94b181a2
Add Trace Hook Macros and function that returns the start of the stack. (#659)
* Add Trace Hook Macros and function that returns the start of the stack.

* Remove obsolete functions.

---------

Co-authored-by: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Co-authored-by: Rahul Kar <karahulx@amazon.com>
Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
1 year ago
chinglee-iot f13ad7789b
Add macro taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD (#780)
* Add macro taskTASK_IS_RUNNING_OR_SCHEDULED_TO_YIELD macro to align single core and SMP
* Update for explicit precedence in vTaskDelete
* Update comment when deleting a running task
1 year ago
chinglee-iot f7565c2d5e
Add configUSE_CORE_AFFINITY bits check (#776)
* Add core affinity bits check
* Add taskBITS_PER_BYTES
1 year ago
chinglee-iot c93d3865f7
Update task running state type and related macros (#770)
* Remove unnecessary type TaskRunning_t
* Rename taskTASK_YIELD to taskTASK_SCHEDULED_TO_YIELD
---------
Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
1 year ago
chinglee-iot 53229b1537
Assert if prvCheckForRunStateChange is called in ISR (#779)
* Assert if prvCheckForRunStateChange is called in ISR
1 year ago
chinglee-iot 288d143357
Update taskSELECT_HIGHEST_PRIORITY_TASK macro for SMP (#777)
* Move the configUSE_PORT_OPTIMISED_TASK_SELECTION check to FreeRTOS.h
* SMP also use taskSELECT_HIGHEST_PRIORITY_TASK macro
---------

Co-authored-by: Soren Ptak <ptaksoren@gmail.com>
1 year ago
chinglee-iot 1aaa318f1c
Update INFINITE_LOOP control (#775)
* Use for loop instead of while loop for INFINITE_LOOP control
1 year ago
Moral-Hao 7372519cba
Use the bigger priority whenever possible. (#760)
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 year ago
kar-rahul-aws cdd3678c29
Add runtime parameter checks (#761)
* Add runtime parameter checks

This commit adds runtime checks for function parameters to mpu_wrappers_v2 file. The same checks are performed
in the API implementation using asserts.

Signed-off-by: kar-rahul-aws <karahulx@amazon.com>
1 year ago
Chien Wong b1a85116bd
Add missing stack alignment adjustment if stack grows upwards (#751)
Signed-off-by: Chien Wong <m@xv97.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2 years ago
kar-rahul-aws 05d93e0990
Fix API for NULL task parameter (#741)
* Fix API for NULL task parameter

* Fix uncrustify

---------

Co-authored-by: Ching-Hsin Lee <chinglee@amazon.com>
2 years ago
ActoryOu dd1b87dae9
Fix RP2040 compile warning (#736)
* Fix Pico compile warning -- port layer

* Warning resolved for volatile discard task.c (#5)

---------

Co-authored-by: Pranjal Chanda <40349163+pranjalchanda08@users.noreply.github.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2 years ago
Gaurav-Aggarwal-AWS 85d2cba801
Fix warning introduced in PR 730 (#735)
The change addresses the following warning:

```
tasks.c:5549:40: warning: assignment discards 'volatile' qualifier from
pointer target type [-Wdiscarded-qualifiers]
 5549 |             pxTaskStatus->pxTopOfStack = pxTCB->pxTopOfStack;
      |
```

Also add the "Build Posix_GCC Demo for Coverage Test" in the PR checks
as coverage test target treats warnings as errors and therefore, will
catch such warnings in PR checks.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2 years ago
ActoryOu 8d80cf697a
Fix Pico compile warning (#732)
* Fix Pico compile warning

* Add type cast for portGET_CORE_ID

---------

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2 years ago