Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/smp granular locks v4 #1154

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Commits on Nov 1, 2024

  1. refactor(freertos/smp): Move critical sections inside xTaskPriorityIn…

    …herit()
    
    xTaskPriorityInherit() is called inside a critical section from queue.c. This
    commit moves the critical section into xTaskPriorityInherit().
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 1, 2024
    Configuration menu
    Copy the full SHA
    9b330c3 View commit details
    Browse the repository at this point in the history
  2. feat(freertos/smp): Allow vTaskPreemptionEnable() to be nested

    Changed xPreemptionDisable to be a count rather than a pdTRUE/pdFALSE. This
    allows nested calls to vTaskPreemptionEnable(), where a yield only occurs when
    xPreemptionDisable is 0.
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 1, 2024
    Configuration menu
    Copy the full SHA
    2be0ff8 View commit details
    Browse the repository at this point in the history
  3. feat(freertos/smp): Add granular locking port macros checks

    Adds the required checks for granular locking port macros.
    
    Port Config:
    
    - portUSING_GRANULAR_LOCKS to enable granular locks
    - portCRITICAL_NESTING_IN_TCB should be disabled
    
    Granular Locking Port Macros:
    
    - Spinlocks
            - portSPINLOCK_TYPE
            - portINIT_EVENT_GROUP_TASK_SPINLOCK( pxSpinlock )
            - portINIT_EVENT_GROUP_ISR_SPINLOCK( pxSpinlock )
            - portINIT_QUEUE_TASK_SPINLOCK( pxSpinlock )
            - portINIT_QUEUE_ISR_SPINLOCK( pxSpinlock )
            - portINIT_STREAM_BUFFER_TASK_SPINLOCK( pxSpinlock )
            - portINIT_STREAM_BUFFER_ISR_SPINLOCK( pxSpinlock )
            - portINIT_KERNEL_TASK_SPINLOCK_STATIC
            - portINIT_KERNEL_ISR_SPINLOCK_STATIC
            - portINIT_TIMERS_TASK_SPINLOCK_STATIC
            - portINIT_TIMERS_ISR_SPINLOCK_STATIC
    - Locking
            - portGET_SPINLOCK()
            - portRELEASE_SPINLOCK()
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 1, 2024
    Configuration menu
    Copy the full SHA
    0e8f12d View commit details
    Browse the repository at this point in the history
  4. feat(granular_locks): Add granular locking functions

    Added or modify granular locking related API:
    
    Added:
    
    - vTaskLockDataGroup()
    - vTaskUnlockDataGroup()
    - uxTaskLockDataGroupFromISR()
    - vTaskUnlockDataGroupFromISR()
    - taskLOCK_DATA_GROUP()
    - taskUNLOCK_DATA_GROUP()
    - taskLOCK_DATA_GROUP_FROM_ISR()
    - taskUNLOCK_DATA_GROUP_FROM_ISR()
    
    Updated:
    
    - Remove prvCheckForRunStateChange() when granular locks is enabled
    - Updated vTaskSuspendAll() and xTaskResumeAll()
        - Now holds the xTaskSpinlock during kernel suspension
        - Increments/decrements xPreemptionDisable. Only yields when 0, thus allowing
        for nested suspensions across different data groups
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 1, 2024
    Configuration menu
    Copy the full SHA
    56d0e10 View commit details
    Browse the repository at this point in the history

Commits on Nov 4, 2024

  1. change(freertos/smp): Update tasks.c locking

    Replaced critical section macros with data group locking macros
    such as taskENTER/EXIT_CRITICAL() with taskLOCK/UNLOCK_KERNEL_DATA_GROUP().
    
    Some tasks.c API relied on their callers to enter critical sections. This
    assumption no longer works under granular locking. Critical sections added to
    the following functions:
    
    - `vTaskInternalSetTimeOutState()`
    - `xTaskIncrementTick()`
    - `vTaskSwitchContext()`
    - `xTaskRemoveFromEventList()`
    - `vTaskInternalSetTimeOutState()`
    - `eTaskConfirmSleepModeStatus()`
    - `xTaskPriorityDisinherit()`
    - `pvTaskIncrementMutexHeldCount()`
    
    Added missing suspensions to the following functions:
    
    - `vTaskPlaceOnEventList()`
    - `vTaskPlaceOnUnorderedEventList()`
    - `vTaskPlaceOnEventListRestricted()`
    
    Fixed the locking in vTaskSwitchContext()
    
    vTaskSwitchContext() must aquire both kernel locks, viz., task lock and
    ISR lock. This is because, vTaskSwitchContext() can be called from
    either task context or ISR context. Also, vTaskSwitchContext() must not
    alter the interrupt state prematurely.
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    cac4f0c View commit details
    Browse the repository at this point in the history
  2. change(freertos/smp): Update queue.c locking

    Updated queue.c to use granular locking
    
    - Added xTaskSpinlock and xISRSpinlock
    - Replaced  critical section macros with data group locking macros
    such as taskENTER/EXIT_CRITICAL() with taskLOCK/UNLOCK_DATA_GROUP().
    - Added prvSuspendQueue() and prvResumeQueue() as the granular locking equivalents
    to prvLockQueue() and prvUnlockQueue() respectively
    - Added missing critical sections to prvNotifyQueueSetContainer()
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    e55151f View commit details
    Browse the repository at this point in the history
  3. change(freertos/smp): Update event_groups.c locking

    Updated event_groups.c to use granular locking
    
    - Added xTaskSpinlock and xISRSpinlock
    - Replaced critical section macros with data group locking macros
    such as taskENTER/EXIT_CRITICAL() with taskLOCK/UNLOCK_DATA_GROUP().
    - Added prvSuspendEventGroup() and prvResumeEventGroup() to suspend the event
    group when executing non-deterministic code.
    - xEventGroupSetBits() and vEventGroupDelete() accesses the kernel data group
    directly. Thus, added vTaskSuspendAll()/xTaskResumeAll() to these fucntions.
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    6ef9c00 View commit details
    Browse the repository at this point in the history
  4. change(freertos/smp): Update stream_buffer.c locking

    Updated stream_buffer.c to use granular locking
    
    - Added xTaskSpinlock and xISRSpinlock
    - Replaced critical section macros with data group locking macros
    such as taskENTER/EXIT_CRITICAL() with taskLOCK/UNLOCK_DATA_GROUP().
    - Added prvSuspendStreamBuffer() and prvResumeStreamBuffer() to suspend the stream
    buffer when executing non-deterministic code.
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    c794d61 View commit details
    Browse the repository at this point in the history
  5. change(freertos/smp): Update timers.c locking

    Updated timers.c to use granular locking
    
    - Added xTaskSpinlock and xISRSpinlock
    - Replaced critical section macros with data group locking macros
    such as taskENTER/EXIT_CRITICAL() with taskLOCK/UNLOCK_DATA_GROUP().
    
    Co-authored-by: Sudeep Mohanty <[email protected]>
    Dazza0 and sudeep-mohanty committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    d840155 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    edc1c98 View commit details
    Browse the repository at this point in the history