weingithub commented on issue #2456:
URL: https://github.com/apache/brpc/issues/2456#issuecomment-1824251933

   > 
大概率会。因为调用bthread_sleep时,bthread会被挂起,等时间到了,会随机选择一个worker线程来调度该bthread,这时候可能已经切换了worker线程了。
 
所以,使用bthread时,不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等)。否则,会导致死锁或者其他未定义行为。
   
非常感谢你的回答,我看https://www.iquanku.com/read/brpc-0.9.7-zh/adb9e61c135a61a7.md这个链接里面的描述的话,好像是如果在bthread中调用pthread_mutex_lock的话,如果是等待拿锁,那么这个时候,bthread是不会切换工作线程的。不知道是不是可以这么理解?
   
![a1](https://github.com/apache/brpc/assets/8966017/64799a34-6f2d-4fca-86cd-2bb7980085b4)
   
   还有个就是,brpc为什么也会导致bthread协程切换?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to