chenBright commented on PR #2907:
URL: https://github.com/apache/brpc/pull/2907#issuecomment-3102341992

   > 即使线程2恰好在线程1在把ready设置为true后读取了ready也不意味着它能看到true,因为同步cache是有延时的。
   
   futex wait 有 release 语义保证别的观察者futex_wake看到futex wait,就能看到wait_num + 
1吧。别的观测者能观测到 waiter num = 
0,不会执行futex_wake,还会有这个保证吗?套用文章的说法就是,即使线程2恰好在线程1在把wait_num + 
1后读取了wait_num也不意味着它能看到大于0,因为同步cache是有延时的。既然有延时的话,也不能保证futex wait后能看到wait_num大于0。
   
   > 如果别的观测者能观测到 waiter num = 0,那么观测者视角来看,futex wait 就一定没执行。
   
   
如你所说,这种情况下,在这个PR之前,futex_wake也是返回0,然后会去signal其他ParkingLot。其实跟这个PR后是一样的。这样的话,应该怎么解释这个PR后,futex
 自旋锁竞争变更多了很多呢?


-- 
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