freertos: Remove/restore queue locks for multi-core/single-core

This commit removes the updates the usage of queue locks in IDF FreeRTOS

Queue locks are present in Vanilla FreeRTOS to ensure that queue functions
behave deterministicly in critical sections (i.e., no walking linked lists
while interrupts are disabled). However, currently in IDF FreeRTOS...

- When configNUM_CORES > 1, IDF FreeRTOS drops the determinism requirement.
Thus, queue functions could be simplified if queue locks were not used at all
(and have a queue function do everything inside the same critical section).

- When configNUM_CORES == 1, the current queue implementation in IDF FreeRTOS
does not meet the determinism requirements, as critical sections are used
(instead of scheduler suspension) when locking/unlocking the queues.

There, this commit updates multiple queue functions so that

- When configNUM_CORES > 1
    - Queue locks are no longer used. All actions are done within the same
      critical section.
    - Affected queue functions now need 40% less CPU clock cycles when blocking
- When configNUM_CORES = 1
    - Queue locks are still used.
    - Vanilla behavior of suspending the scheduler is restored when locking
      the queue. Thus queue fucntions are now deterministic and have the same
      behavior as Vanilla FreeRTOS.
    - Affected queue functions now takes 36% more CPU clock cycles when
      blocking (due to the scheduler suspension/resumption).
This commit is contained in:
Darian Leung 2022-11-04 22:43:25 +08:00
parent 8fe79ae0cd
commit ae3383ddc5
2 changed files with 660 additions and 477 deletions

File diff suppressed because it is too large Load Diff

View File

@ -97,7 +97,10 @@ entries:
event_groups: xEventGroupSetBits (default)
event_groups: xEventGroupSync (default)
event_groups: vEventGroupDelete (default)
queue: prvIsQueueFull (default)
if FREERTOS_UNICORE = y:
queue: prvUnlockQueue (default)
queue: prvIsQueueEmpty (default)
queue: prvIsQueueFull (default)
queue: prvInitialiseNewQueue (default)
queue: prvInitialiseMutex (default)
queue: uxQueueSpacesAvailable (default)