@herbschi , if it helps I have tested Mutex's on my Giga running the arduino mbed core and they work in my setup.
Here's my code (running in my test harness on the Giga - hence the SCENARIO boilerplate):
#include <Arduino.h>
#include <Thread.h>
#include "doctest/doc-test-harness.h" // Just the test harness
#include "logger/logger.h" // just the logger
static rtos::Mutex m;
static void ping() {
while (true) {
m.lock();
DBC_INFO(subsystem::test, "ping");
delay(1000);
m.unlock();
}
}
static void pong() {
while (true) {
m.lock();
DBC_INFO(subsystem::test, "pong");
delay(10000);
m.unlock();
}
}
SCENARIO("giga-threads") {
rtos::Thread t1;
rtos::Thread t2;
t1.start(ping);
delay(5000);
t2.start(pong);
t1.join();
t2.join();
}
What I expect to see is ping messages every second for 5 seconds then when t2 is started it'll lock for 10s and I will see the ping stop for 10 seconds.
You can see this in the results below:
INFO: <--- TEST LOG :dt=2024-10-01 15:46:27,:l=I,:c=M7,:s=test,ping
INFO: <--- TEST LOG :dt=2024-10-01 15:46:28,:l=I,:c=M7,:s=test,ping
INFO: <--- TEST LOG :dt=2024-10-01 15:46:29,:l=I,:c=M7,:s=test,ping
INFO: <--- TEST LOG :dt=2024-10-01 15:46:30,:l=I,:c=M7,:s=test,ping
INFO: <--- TEST LOG :dt=2024-10-01 15:46:31,:l=I,:c=M7,:s=test,ping
INFO: <--- TEST LOG :dt=2024-10-01 15:46:32,:l=I,:c=M7,:s=test,pong <--- see the 10s after this
INFO: <--- TEST LOG :dt=2024-10-01 15:46:42,:l=I,:c=M7,:s=test,ping
INFO: <--- TEST LOG :dt=2024-10-01 15:46:43,:l=I,:c=M7,:s=test,pong
I'm happy to run a trivial test case for you if you post one here.