如果碰巧已经锁定了互斥对象,调用者将进入睡眠状态。
If the mutex already happens to be locked, the caller will go to sleep.
可以推测到,当线程试图锁定一个未加锁的互斥对象时,POSI x线程库将同意锁定,而不会使线程进入睡眠状态。
As you may have guessed, the POSIX threads library will grant a lock without having put the thread to sleep at all if a thread tries to lock an unlocked mutex.
对已锁定的互斥对象上调用pthread _ mutex_lock的所有线程都将进入睡眠状态,这些睡眠的线程将“排队”访问这个互斥对象。
All threads that go to sleep from calling pthread_mutex_lock on an already-locked mutex will "queue up" for access to that mutex.
应用推荐