Hello,
I'm hacking ChibiOS with mutex synchronization mechanism and testing demo code in `demo/RT-Posix-simulator`. It's amazing that mutex support PIP and recursive token in such code base.
However, There is a little weird about why mutex in ChibiOS/RT doesn't support timeout? I found that semaphore and condition variable support timeout. If I want to do something like `pthread_mutex_timeoutlock()`, is it possible?
How to make mutex support timeout?
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: How to make mutex support timeout?
Hi,
It would be possible to add timeout to mutexes but it would be computationally complex because PIP, on timeout the thread would have to "recall" the priority boost that it gave to the thread(s) holding the mutex.
This is why it is not implemented, unlike all other mechanisms.
Without this "priority un-boost" thing it would be easy to add but the behavior would not be correct.
Giovanni
It would be possible to add timeout to mutexes but it would be computationally complex because PIP, on timeout the thread would have to "recall" the priority boost that it gave to the thread(s) holding the mutex.
This is why it is not implemented, unlike all other mechanisms.
Without this "priority un-boost" thing it would be easy to add but the behavior would not be correct.
Giovanni
-
- Posts: 141
- Joined: Mon Sep 25, 2017 8:27 am
- Location: Canberra, Australia
- Has thanked: 10 times
- Been thanked: 20 times
- Contact:
Re: How to make mutex support timeout?
If anyone has implemented mutex with timeout and priority inheritance then please let me know. It would be very useful for ArduPilot. As giovanni said, it does look quite complex to implement, but would be a really nice feature.
Who is online
Users browsing this forum: No registered users and 34 guests