万恶的Soft Deadlock!

在调试开发板时遇到进程卡死问题,通过日志发现涉及Soft Deadlock。PJSIP官网解释了Soft Deadlock是由于应用设计问题导致的短暂冻结,而非永久性死锁。当回调函数、工作线程与PJSUA-LIB锁获取顺序不当时,会出现此现象。解决方案需要改进应用设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天调试开发板,突然出现画面卡死不动了,top 之后发现 所有的进程都在没有崩溃退出的现象。

调查LOG,显示如下LOG,

 

 17:14:59.547   pjsua_call.c  Timed-out trying to acquire dialog mutex (possibly system has deadlocked) in pjsua_call_hangup()

 

经过多方调查,在PJSIP官网上 发现如下的解释:

===================================================================

Soft Deadlock

Although hard deadlock (where application just freezes) should never happen when the above guidelines are used, there may be cases when application gets a soft deadlock state. When this happens, application will not freeze permanently, but rather it will freeze for few seconds while PJSUA-LIB is trying to acquire the locks, and these message may appear in the log afterwards:

Timed-out trying to acquire PJSUA mutex (possibly system has deadlocked) in pjsua_xxx

This could happen for example in the following scenario:

  1. application callback is called
  2. application posts a job to a worker thread, and blocks until it gets result from the worker thread
  3. the worker thread calls some PJSUA-LIB call API
  4. when PJSUA-LIB tries to acquire locks with acquire_call() on behalf of the worker thread, it will fail to get them because the locks are currently being held by the callback thread (in step no 1 above). In this case, rather than deadlocking permanently, PJSUA-LIB will timeout after it retries acquiring the locks for few seconds, and returns PJ_ETIMEDOUT error to acquire_call() caller.

This is a generic application design problem, and is not caused by PJSUA-LIB (in fact PJSUA-LIB has helped us here by not deadlocking permanently).

As for the solution, quoting the famous saying: I'll leave that as an exercise for the reader. ;-) -->这个问题留给各位看官解决哦!

Soft Deadlock When Working with Multiple Calls

Ticket #1371 reports another soft deadlock case when working with multiple calls.

==============================

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值