destroy pthread_mutex_lock 会怎么样???
请问会有什么后果?锁会被打开么? 线程会怎么走:
一个线程中阻塞于 pthread_mutex_lock(&mutexSync);
另一个线程中 pthread_mutex_destroy(&mutexSync);
一个线程中阻塞于 sem_wait(&Sync);
另一个线程中 sem_destroy(&Sync);
------解决方案--------------------好吧, 第二个可以容忍, 但第一个恐怕行不通噢.
------解决方案-------------------- EBUSY The implementation has detected an attempt to destroy the object referenced by mutex while it is locked or referenced (for example, while being used
in a pthread_cond_timedwait() or pthread_cond_wait()) by another thread.
------解决方案--------------------
It is safe to destroy an initialized semaphore upon which no threads are currently blocked. The effect of destroying a semaphore upon which other threads
are currently blocked is undefined.
------解决方案--------------------不好意思,我回答错误了,关于释放使用中的互斥锁和信号量确实可以正确返回,我测试的行为也是正常的,但文档确实明文说了是会导致不确定行为。我查询了内核代码发现确实会导致不确定行为,I am sorry 可能误导了你。