Recursive mutex / newlib retarget lock support #276
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#276
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Please add support for recursive mutex
mutex_enter_blocking_recursive()
mutex_try_enter_recursive()
mutex_exit_recursive()
ping @kilograham
just for info ... look this
https://github.com/Wiz-IO/LIB/blob/master/pico/pico_mutex/mutex.c#L82
new is only one counter in mutex_t
https://github.com/Wiz-IO/LIB/blob/master/pico/pico_mutex/mutex.h#L35
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.
recursive mutex is used for "future" ..... <sys/lock.h> as baremetal and/or FreeRTOS to protect the stdio and file system
example: unistd and FILE in Arduino (C++)

RAM Disk + FLASH Disk + SD Card
posix? :) ... need only 5 functions for pthread...
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?
https://github.com/Wiz-IO/framework-wizio-pico/blob/main/wizio/newlib/lock.c
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).
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
Note recursive mutexes will be added by #378
...have been added... 🙂 (i.e. this can be closed?)
yep close
this days will test...