Re: [I] bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? (brpc)
weingithub commented on issue #2456: URL: https://github.com/apache/brpc/issues/2456#issuecomment-1825077138 > > > 不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等) > > > > > > 不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等)。这个rpc不是指brpc吗? > > 是的。异步rpc应该不会有问题,同步rpc在发完数据后,会调用Join等回包,会挂起bthread。 > > https://github.com/apache/brpc/blob/806f4d46c9393f6aeb92aa558d95fe95d1784355/src/brpc/channel.cpp#L576-L587 谢谢啦。 -- 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
Re: [I] bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? (brpc)
weingithub closed issue #2456: bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? URL: https://github.com/apache/brpc/issues/2456 -- 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
Re: [I] bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? (brpc)
chenBright commented on issue #2456: URL: https://github.com/apache/brpc/issues/2456#issuecomment-1825071326 > > 不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等) > > 不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等)。这个rpc不是指brpc吗? 是的。异步rpc应该不会有问题,同步rpc在发完数据后,会调用bthread::Join等回包,会挂起bthread。 https://github.com/apache/brpc/blob/806f4d46c9393f6aeb92aa558d95fe95d1784355/src/brpc/channel.cpp#L576-L587 -- 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
Re: [I] bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? (brpc)
weingithub commented on issue #2456: URL: https://github.com/apache/brpc/issues/2456#issuecomment-1824329110 > 不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等) 不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等)。这个rpc不是指brpc吗? -- 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
Re: [I] bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? (brpc)
chenBright commented on issue #2456: URL: https://github.com/apache/brpc/issues/2456#issuecomment-1824303473 > 如果在bthread中调用pthread_mutex_lock的话,如果是等待拿锁,那么这个时候,bthread是不会切换工作线程的。不知道是不是可以这么理解? 是的 > brpc为什么也会导致bthread协程切换? 不懂这个问题是什么意思?brpc? -- 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
Re: [I] bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? (brpc)
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
Re: [I] bthread在持有了pthread的锁之后,如果遇到bthread_sleep的调用,是否会切换工作线程?? (brpc)
chenBright commented on issue #2456: URL: https://github.com/apache/brpc/issues/2456#issuecomment-1824058567 调用bthread_sleep时,bthread会被挂起,等时间到了,会随机选择一个worker线程来调度该bthread,这时候可能已经切换了worker线程了。所以,使用bthread时,不能在pthread锁临界区内执行会挂起bthread的操作(bthread_mutex、rpc、bthread_usleep等)。否则,会导致死锁或者其他未定义行为。 -- 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