阅读背景:

在信号处理程序中销毁pthread mutex / rwlock

来源:互联网 

How to correctly destroy pthread mutex or rwlock in signal handler? For example - in the code below i has main thread and 3 another threads. All threads do some tasks in infinity loop on some array, using mutexes and locks. Because main thread is also doing some task, the only way to exit from program - using signal handler. But in this way i can't destroy my mutex/rwlock object, because there's no guarantee that object is unlocked. And if I'll try to unlock it, of course one of thread will lock it again. And when i'm trying to launch my program again, that print corrupted result. So how can i solve this problem? There is example of my code with rwlocks:How to correctly destroy pthread mutex or rwloc




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: