如果碰巧已经锁定了互斥对象,调用者将进入睡眠状态。
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.
同样地,当线程a正锁定互斥对象时,如果线程c试图锁定互斥对象的话,线程c也将临时进入睡眠状态。
Likewise, if thread "c" tries to lock the mutex while thread "a" is holding it, thread "c" will also be put to sleep temporarily.
如果线程a试图锁定一个互斥对象,而此时线程b已锁定了同一个互斥对象时,线程a就将进入睡眠状态。
If thread "a" tries to lock a mutex while thread "b" has the same mutex locked, thread "a" goes to sleep.
如果线程a试图锁定一个互斥对象,而此时线程b已锁定了同一个互斥对象时,线程a就将进入睡眠状态。
If thread "a" tries to lock a mutex while thread "b" has the same mutex locked, thread "a" goes to sleep.
应用推荐