Skip to content

Conversation

@HiFiPhile
Copy link
Collaborator

Describe the PR
To allow it be used in nested functions, I think most OSs already have the counter.

Copilot AI review requested due to automatic review settings November 7, 2025 10:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds nested locking support to the bare-metal spinlock implementation in osal_none.h. The enhancement allows the same execution context to acquire a spinlock multiple times without deadlocking, which is crucial for single-core bare-metal systems where nested critical sections are common.

Key changes:

  • Added nested_count field to track lock depth and prevent premature interrupt re-enabling
  • Modified lock/unlock logic to only disable/enable interrupts on the outermost lock/unlock
  • Added underflow detection to catch mismatched lock/unlock pairs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant