[riot-notifications] [RIOT-OS/RIOT] core/mutex: Add mutex_cancel (#15442)
Marian Buschsieweke
notifications at github.com
Mon Nov 16 11:18:48 CET 2020
> but, what happens when the lock gets canceled anyways? (locker uses "mutex_lock()", but someone calls "mutex_cancel()" on it?
`mutex_lock()` must never fail :-)
Btw: I think I will place a preconditions that `mutex_lock_may_fail()` is called with IRQs disabled. This would get rid of all the complexity, as one could simply do:
```C
setup_isr_that_unblocks_mutex_but_mask_it();
unsigned state = irq_disable();
unmask_isr_that_unblocks_mutex();
if (mutex_lock_may_fail(&mut, state) == 0) {
work_on_shared_data();
mutex_unlock();
}
```
Here there is no chance that the ISR hits right before the call to `mutex_lock_may_fail()`, and all those abuse `wait_data` to signal cancellation is no longer needed. So not even a pseudo-module would be required to enable it, as the linker would be totally capable to garbage collect every single byte of RAM and ROM needed by this.
--
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#issuecomment-727882886
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201116/b4e2b5ee/attachment-0001.htm>
More information about the notifications
mailing list