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

Implementation of osKernelRestoreLock is dangerous and might leave the kernel locked #109

Closed
pakluba opened this issue Jul 22, 2024 · 2 comments
Assignees
Labels

Comments

@pakluba
Copy link
Contributor

pakluba commented Jul 22, 2024

case taskSCHEDULER_SUSPENDED:

Unlike RTX, FreeRTOS does nesting in vTaskSuspendAll(). If the scheduling has already been suspended before osKernelLock() is called, osKernelRestoreLock() will increase the nesting level by 1 instead of removing 1 lock. So:

vTaskSuspendAll();           // the nesting level is at least 1
...
state = osKernelLock();      // does not increase nesting, returns 1 (was locked already)
...
osKernelRestoreLock(state);  // will call vTaskSuspendAll() to "restore" the lock -> boom...
@VladimirUmek
Copy link
Collaborator

Hello,
good find, thanks! I'll review the implementation and provide a fix.

@VladimirUmek VladimirUmek self-assigned this Jul 22, 2024
pakluba added a commit to pakluba/CMSIS-FreeRTOS that referenced this issue Aug 9, 2024
…RM-software#109)

The scheduler state checking has been removed as the scheduler being locked out
could still be valid due to the nesting.
VladimirUmek pushed a commit that referenced this issue Aug 19, 2024
)

The scheduler state checking has been removed as the scheduler being locked out
could still be valid due to the nesting.
@VladimirUmek
Copy link
Collaborator

Thanks you for going forward and providing the PR! It has been merged hence I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants