mutex does nothing?
https://github.com/rochus-keller/CspChan/blob/6867c1a28e1443633bb99b65652bf58f033f5bb9/CspChan.c#L404
For that line, since mtx is local to the function, every call to the function from a different thread will get a different mtx, so it's not clear what the purpose of this mutex is.
That's a pretty specific question concerning tricky code I wrote two years ago ;-)
To answer that, I actually have to familiarize myself with the code, so bear with me if I don't get it right away.
The mtx mutex in CspChan_select is mostly required because of the sig condition variable. The goal is a synchronization of the specific select operation. Each call of CspChan_select has its own synchronization state to avoid interference between concurrent selects. The mutex protects only the sig condition variable and the ready array used during the select’s polling phase. So it's better to keep it local.
But to understand everything properly, I would have to familiarize myself with it again. It took me quite some time back then to get the synchronization right. Maybe I still have the notes somewhere.