Hi!
2025-03-25 at 19:04, Srinivas Kandagatla wrote:
I wish we could be taken care in mux-core or even in the deselect api
It is not easily done. A mux is a shared resource. How can the mux core
know if it is consumer A or consumer B that deselects the mux if both
ignore failures when calling select? Mux select is backed by a semaphore
and there is no guarantee that a consumer selects/deselects from the
same thread or anything like that. The onus is on the consumer to get
this right and only deselect when select is successful.
I believe the documentation is clear on this topic: "do not call
mux_control_deselect() if mux_control_select() fails".
exclusive apis would simplify the consumer side of code for sure.
One thing can be done from the mux core, and that is to provide a new
API where consumers get a mux that is exclusive so that the consumer
can call select/deselect without involving a lock in the core. There
need not even be a requirement to call deselect between selects in that
case. Such an API is what many consumers want, I think, but it is of
course not really compatible with the existing API, which is totally
focused on the need to share a mux among multiple consumers.
And, of course, someone has to do it.
Cheers,
Peter