what is the correct behavior of pthread_mutex_destroy when destroying a locked mutex

 ̄綄美尐妖づ 提交于 2019-12-05 20:19:27

The quoted text:

Attempting to destroy a locked mutex or a mutex that is referenced (for example, while being used in a pthread_cond_timedwait() or pthread_cond_wait()) by another thread results in undefined behavior.

Should be interpreted with the "results in undefined behavior" clause distributed over the "or" conjunction. In other words:

Attempting to destroy a locked mutex results in undefined behavior.

and

Attempting to destroy a mutex that is referenced (for example, while being used in a pthread_cond_timedwait() or pthread_cond_wait()) by another thread results in undefined behavior.

The second version is significant, because when waiting on the condition variable, the associated mutex lock is released by the waiting thread.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!