semphr: implement the FreeRTOS recursive mutex API#199
Draft
faisal-shah wants to merge 1 commit into
Draft
Conversation
InfiniTime is gaining a recursive mutex inside Controllers::FS to make littlefs access thread-safe (InfiniTimeOrg/InfiniTime#2449). The firmware's FS.cpp is compiled into the simulator and littlefs-do, so the shim needs xSemaphoreCreateRecursiveMutex, xSemaphoreTakeRecursive and xSemaphoreGiveRecursive. Backed by std::recursive_mutex. The timeout argument is ignored: the only firmware caller uses portMAX_DELAY, matching the blocking lock. Handles from xSemaphoreCreateRecursiveMutex must only be used with the *Recursive functions and vice versa, the same rule real FreeRTOS imposes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to InfiniTimeOrg/InfiniTime#2449, which adds a recursive mutex inside
Controllers::FSto make littlefs access thread-safe. The firmware'sFS.cppis compiled into both the simulator andlittlefs-do, so the FreeRTOS shim needsxSemaphoreCreateRecursiveMutex,xSemaphoreTakeRecursiveandxSemaphoreGiveRecursive.Implementation: a
std::recursive_mutexbehind the semaphore handle. The timeout argument is ignored; the only firmware caller usesportMAX_DELAY, matching the blocking lock. Handles fromxSemaphoreCreateRecursiveMutexmust only be used with the*Recursivefunctions and vice versa, which is the same rule real FreeRTOS imposes.This change is additive and safe to merge independently: it compiles against current InfiniTime main (the new functions are simply unused until the FS change lands). Verified locally in the same combination InfiniTime's
build-simulatorCI job uses: this branch built with-DInfiniTime_DIRpointing at InfiniTime main plus the FS mutex patch, bothinfinisimandlittlefs-dolink and run.Merging this first unblocks the
build-simulatorcheck on the InfiniTime PR, since that job clones InfiniSim main.