You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2021/07/24 13:49:33 UTC

[GitHub] [incubator-brpc] charyxiao opened a new issue #1497: butex_wait & remind相关问题

charyxiao opened a new issue #1497:
URL: https://github.com/apache/incubator-brpc/issues/1497


   butex_wait 函数看代码有几点疑问
   1. wait_for_butex 为什么不原地执行?为什么要放到remind里
   2. wait_for_butex之后的sched如果切换的bthread上下文的代码断点在task_runner的thread_return = m->fn(m->arg)中,那就不会执行g->_last_context_remained的信息 相反会重新调用g->set_remained,将wait_for_butex冲掉
   ![image](https://user-images.githubusercontent.com/5407327/126870356-8dfec3bf-a3b2-4cf5-8881-2fb15381ea7c.png)
   
   
   
   


-- 
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-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] jenrryyou commented on issue #1497: butex_wait & remained相关问题

Posted by GitBox <gi...@apache.org>.
jenrryyou commented on issue #1497:
URL: https://github.com/apache/incubator-brpc/issues/1497#issuecomment-891484786


   有同样的疑惑。另外如果切换的后的bthread再次调用butex_wait,会不会覆盖task_group的remained回调?


-- 
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-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] charyxiao commented on issue #1497: butex_wait & remained相关问题

Posted by GitBox <gi...@apache.org>.
charyxiao commented on issue #1497:
URL: https://github.com/apache/incubator-brpc/issues/1497#issuecomment-894795553


   第二点 调用sched(&g) 不一定是调度新的bthread的 也可能是旧的bthread的 举个更极端的例子 如果没有新的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-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] jenrryyou commented on issue #1497: butex_wait & remained相关问题

Posted by GitBox <gi...@apache.org>.
jenrryyou commented on issue #1497:
URL: https://github.com/apache/incubator-brpc/issues/1497#issuecomment-891487709


   对第一点有同样的疑问;
   第二点我的理解是:wait_for_butex里直接调用的是`TaskGroup::sched(&g)`,会调度新的`bthread`,一定会从头执行`task_runner`,把之前设置的回调执行;
   ![image](https://user-images.githubusercontent.com/4698734/127952379-1fc7d2b3-af2f-48ef-9e2a-d23075c77afd.png)
   


-- 
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-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] jenrryyou removed a comment on issue #1497: butex_wait & remained相关问题

Posted by GitBox <gi...@apache.org>.
jenrryyou removed a comment on issue #1497:
URL: https://github.com/apache/incubator-brpc/issues/1497#issuecomment-891484786


   有同样的疑惑。另外如果切换的后的bthread再次调用butex_wait,会不会覆盖task_group的remained回调?


-- 
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-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] jenrryyou edited a comment on issue #1497: butex_wait & remained相关问题

Posted by GitBox <gi...@apache.org>.
jenrryyou edited a comment on issue #1497:
URL: https://github.com/apache/incubator-brpc/issues/1497#issuecomment-891487709


   对第一点有同样的疑问;
   第二点我的理解是:`butex_wait`里直接调用的是`TaskGroup::sched(&g)`,会调度新的`bthread`,一定会从头执行`task_runner`,把之前设置的回调执行;
   ![image](https://user-images.githubusercontent.com/4698734/127952379-1fc7d2b3-af2f-48ef-9e2a-d23075c77afd.png)
   


-- 
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-unsubscribe@brpc.apache.org

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



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


[GitHub] [incubator-brpc] ZeroLiu2018 commented on issue #1497: butex_wait & remained相关问题

Posted by GitBox <gi...@apache.org>.
ZeroLiu2018 commented on issue #1497:
URL: https://github.com/apache/incubator-brpc/issues/1497#issuecomment-962740435


   > 第二点 调用sched(&g) 不一定是调度新的bthread的 也可能是旧的bthread的 举个更极端的例子 如果没有新的bthread呢
   
   我说一下我的理解,先说第二点:除了 task_runner ,在 sche_to 里面,jump_stack 完成返回后,也会执行 _last_context_remained,也就是说在真正切到另一个 bthread 跑逻辑前,都会执行 _last_context_remained。
   然后就是第一点,在第一点之前你可以看看切换 bthread 的逻辑,切换 bthread 之前有个 set_remained, 这个 remianed 的作用是将当前 bthread 放到队列。它也同样不是在原地执行,我想两者的原因是一样的(wait_for_butex 里面同样有将当前 bthread 入队的逻辑): 需要调度出新的 bthread 才能将旧 bthread 入列,否则,stack 切换可能很难处理。


-- 
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-unsubscribe@brpc.apache.org

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



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