本文介绍了互斥在共享内存时一个用户崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设一个进程创建共享内存中的互斥和锁定它,而互斥被锁定转储核心。
Suppose that a process is creating a mutex in shared memory and locking it and dumps core while the mutex is locked.
现在在另一个进程中,我怎样检测的互斥锁已经锁定,但没有任何进程拥有?
Now in another process how do I detect that mutex is already locked but not owned by any process?
推荐答案
如果使用Linux或类似的东西,可考虑使用的的,而不是(我假设是什么)pthreads的互斥。我不认为有一种方法来确定一个pthreads的互斥的锁定PID,短构建自己的报名表,并把它在共享内存。
If you're working in Linux or something similar, consider using named semaphores instead of (what I assume are) pthreads mutexes. I don't think there is a way to determine the locking PID of a pthreads mutex, short of building your own registration table and also putting it in shared memory.
这篇关于互斥在共享内存时一个用户崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!