czg*_*czg 1 c linux synchronization mutex pthreads
我pthread_mutex_t在我的程序中使用线程同步控制。当不再使用
时,我需要做一些整理工作吗?
或者说,我可以什么都不做吗?pthread_mutex_t
感谢您的帮助
您提到“pthread_mutex_t 不再使用”。
我假设您的意思是您不再需要在任何线程中使用它。
在这种情况下:
pthread_mutex_t处于解锁状态。pthread_mutex_destroy。互斥体解锁的要求出现在以下文档中pthread_mutex_destroy:
销毁已解锁的初始化互斥锁应该是安全的。尝试破坏锁定的互斥体会导致未定义的行为。
(重点是我的)
这篇文章包含有关正确使用以下内容的更多信息pthread_mutex_destroy:
How to secure and Correctly destroy a mutex in Linux using pthread_mutex_destroy? 。