Message 103500 - Python tracker (original) (raw)

Martin, I don't know if you were suggesting that a "fair" mutex would make the emulated semaphore fair too. You probably weren't, but just in case, the fairness of the mutex is immaterial because it is only held for a short time to guard the internal state of the "semaphore". You won't see threads queing up on it, but they will queue on the Contition variable.

Exactly so. I still don't see why you then infer that the GIL is unfair. It is not IF THE CONDITION VARIABLE IS FAIR. As I said, some implementations of condition variables are fair, e.g. the Linux one (which in itself isn't really relevant here, because Linux uses the semaphore GIL, anyway). However, it remains unclear why you think that the GIL is not fair in pthreads.