Program creates a PTHREAD_MUTEX_ADAPTIVE_NP mutex, and now thread A gets the lock. Three threads(B, C, D) compete for this lock when thread A give it. What I wonder is, why the thread which have waited for the longest time always first gets this lock and then the second longest time thread...and so on.
I think PTHREAD_MUTEX_ADAPTIVE_NP is like pthread_spinlock just like answer of Kaz Sir in What is PTHREAD_MUTEX_ADAPTIVE_NP: The approach is also not suitable in situations in which fairness is important: it is an opportunistic lock.