Will a thread waiting on a mutex get the ownership, immediately after mutex_unlock() by other thread?
问题 I have two threads - threadA & threadB. If B is waiting for mutex, which is owned by A, Will it get the ownership immediately after A unlocks it, assuming it has higher priority than A ? This not a question on who gets the lock when multiple threads are waiting, but if a single waiting thread becomes runnable & gets the processor or not. From the test example below it doesn't seem to happen always. Can someone please clarify ? #include <stdio.h> #include <stdlib.h> #include <unistd.h>