[riot-notifications] [RIOT-OS/RIOT] core/mutex: Add mutex_cancel (#15442)

Marian Buschsieweke notifications at github.com
Tue Nov 17 11:23:00 CET 2020


@maribu commented on this pull request.



> @@ -33,21 +33,20 @@
 #define ENABLE_DEBUG 0
 #include "debug.h"
 
-int mutex_lock(mutex_t *mutex)
+/**
+ * @brief   Block waiting for a locked mutex
+ * @pre     IRQs are disabled

Wait, this is right. I just saw the `mutex_lock` and misread as if I added this to `mutex_lock()` somehow.

And `irq_state` is need in case someone does stuff like:

```C
    unsigned state = irq_disable();
    mutex_lock(&mut);
    other_stuff_with_irqs_disabled_i_know_this_is_stupid();
    irq_restore(state);    
```

I don't this that there is a valid use case for the above code. But IMO we shouldn't judge what application developers implement. And if they want to do stupid stuff, the should certainly be able to do stupid stuff in a safe manner.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15442#discussion_r525042356
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201117/251228a2/attachment.htm>


More information about the notifications mailing list