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

Recursive mutex / newlib retarget lock support #276

Closed
Wiz-IO opened this issue Mar 14, 2021 · 12 comments
Closed

Recursive mutex / newlib retarget lock support #276

Wiz-IO opened this issue Mar 14, 2021 · 12 comments
Labels
newlib newlib-multicore rtos interop Consideration for FreeRTOS co-existence
Milestone

Comments

@Wiz-IO
Copy link

Wiz-IO commented Mar 14, 2021

Please add support for recursive mutex
mutex_enter_blocking_recursive()
mutex_try_enter_recursive()
mutex_exit_recursive()

@lurch
Copy link
Contributor

lurch commented Mar 14, 2021

ping @kilograham

@Wiz-IO
Copy link
Author

Wiz-IO commented Mar 19, 2021

@kilograham
Copy link
Contributor

results with <sys/lock.h>
no locks
with locks

Not 100% sure what you are trying to indicate here... I know what a mutex does :-) ... FYI printf in the SDK is already mutex-ed for you by default.

@Wiz-IO
Copy link
Author

Wiz-IO commented Mar 19, 2021

recursive mutex is used for "future" ..... <sys/lock.h> as baremetal and/or FreeRTOS to protect the stdio and file system

@Wiz-IO
Copy link
Author

Wiz-IO commented Mar 19, 2021

example: unistd and FILE in Arduino (C++)
RAM Disk + FLASH Disk + SD Card
posix? :) ... need only 5 functions for pthread...
unistd

@kilograham kilograham transferred this issue from raspberrypi/pico-feedback Mar 22, 2021
@kilograham
Copy link
Contributor

So the existing mutex classes should not be used in a FreeRTOS as they are core not task focused (unless you specifically mean core).

Equally, should a recursive mutex be successfully claimed by both application and IRQ on the same core?

@Wiz-IO
Copy link
Author

Wiz-IO commented Mar 24, 2021

@kilograham
Copy link
Contributor

kilograham commented Mar 25, 2021

showing me that code doesn't really answer my question, though I am able to glean that you seem to want the recursive mutexes to work the way that makes them suitable for using in newlib locking (which isn't documented there). (edit i mean you showed me locks that are re-entrant on the same core, I still don't know if this is desirable behavior though for an IRQ to be able to take a lock owned by the application code).

Can you point me at some docs for the newlib locking - since you seem to be implementing the locks defined somewhere, because fixing enabling newlib re-entrancy/locking when using multicore via the raw SDK is likely a good thing anyway (note I was assuming the newlib that comes with gcc just didn't support it, but I guess I am wrong).

@Wiz-IO
Copy link
Author

Wiz-IO commented Mar 25, 2021

I was looking for documents for newlib
found only this...
https://www.cs.ccu.edu.tw/~pahsiung/courses/ese/resources/newlib.pdf

and I applied this in reverse
https://gist.github.com/thomask77/65591d78070ace68885d3fd05cdebe3a

here is my version (as idea)
is only one counter in mutex_t and this
https://github.com/Wiz-IO/framework-wizio-pico/blob/main/SDK/pico/pico_sync/mutex.c#L82

@kilograham kilograham added this to the 1.3 milestone Mar 27, 2021
@kilograham kilograham changed the title Recursive mutex Recursive mutex / newlib retarget lock support May 4, 2021
@kilograham
Copy link
Contributor

Note recursive mutexes will be added by #378

@kilograham kilograham added the rtos interop Consideration for FreeRTOS co-existence label May 4, 2021
@lurch
Copy link
Contributor

lurch commented May 6, 2021

...have been added... 🙂 (i.e. this can be closed?)

@Wiz-IO
Copy link
Author

Wiz-IO commented May 6, 2021

yep close
this days will test...

@kilograham kilograham modified the milestones: 1.5.0, 1.2.0 Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
newlib newlib-multicore rtos interop Consideration for FreeRTOS co-existence
Projects
None yet
Development

No branches or pull requests

3 participants