动态库卸载时同步停止用线程死锁
来源:互联网 发布:阿里云华北一地址 编辑:程序博客网 时间:2024/05/09 16:50
原因参照:
https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx
Best Practices for Synchronization
Thread Synchronization in DllMain for DLL_THREAD_DETACH during DLL Unload
- When the DLL is unloaded, the address space is not thrown away. Therefore, the DLL is expected to perform a clean shutdown. This includes thread synchronization, open handles, persistent state, and allocated resources.
- Thread synchronization is tricky because waiting on threads to exit in DllMain can cause a deadlock. For example, DLL A holds the loader lock. It signals thread T to exit and waits for the thread to exit. Thread T exits and the loader tries to acquire the loader lock to call into DLL A’s DllMain with DLL_THREAD_DETACH. This causes a deadlock. To minimize the risk of a deadlock:
- DLL A gets a DLL_THREAD_DETACH message in its DllMain and sets an event for thread T, signaling it to exit.
- Thread T finishes its current task, brings itself to a consistent state, signals DLL A, and waits infinitely. Note that the consistency-checking routines should follow the same restrictions as DllMain to avoid deadlocking.
- DLL A terminates T, knowing that it is in a consistent state.
0 0
- 动态库卸载时同步停止用线程死锁
- 2017.4.17线程同步死锁、线程通信、线程停止
- 线程同步 线程死锁
- 线程同步/线程死锁
- 线程同步之死锁
- 同步线程锁 死锁
- 线程同步---死锁
- 线程同步于死锁
- 线程同步与死锁
- 线程同步 · 死锁
- 线程同步与死锁
- 线程同步与死锁
- 线程同步和死锁
- 线程同步之死锁
- 线程--同步与死锁
- 线程同步、死锁原理
- 线程同步和线程死锁
- 线程同步和线程死锁
- 建堆
- PHP 下载 file_put_contents vs readfile
- pip install scipy
- POJ2488 A Knight's Journey[dfs]
- jsp页面导包和<jsp:userBean>
- 动态库卸载时同步停止用线程死锁
- 画板项目之后的感想
- Android 开机动画制作 bootanimation.zip
- 【spring】BeanPostProcessor简介
- Windows电脑如何共享文件给Mac苹果电脑【详细教程】
- 二叉树
- 云游戏对于Android来说可行吗?
- Java开源报表JasperReport、iReport4.5.1使用详解(二)
- 全局变量的内部链接