ivechan 最近的时间轴更新
ivechan

ivechan

V2EX 第 175176 号会员,加入于 2016-05-29 19:53:40 +08:00
ivechan 最近回复了
2022-05-25 19:13:32 +08:00
回复了 fanxasy 创建的主题 Java fastjson 真就突出一个阴魂不散
国外很多开源软件其实也有漏洞。。。大可平常心看待。
2022-04-10 00:02:21 +08:00
回复了 dangyuluo 创建的主题 C++ CPU 指令重排是 cache 同步太慢的表征么?
《 A Primer on Memory Consistency and Cache Coherence 》可以滤清概念
偏实践的话可以看 https://www.kernel.org/doc/Documentation/memory-barriers.txt
(怎么用 MB )
2022-04-09 23:55:12 +08:00
回复了 dangyuluo 创建的主题 C++ CPU 指令重排是 cache 同步太慢的表征么?
@dahakawang 《 A Primer on Memory Consistency and Cache Coherence 》 没有问题吧。
介绍的都是实际中常见的内存模型,比如 X86 ( TSO )。
这个和某个 specific implementation 没有任何关系.
正如 @nlzy 说的一样,内存模型是一个架构的规范,和微架构实现没有关系。
所有 x86 都是 TSO 的,没有什么例外。
2021-08-15 08:09:45 +08:00
回复了 hxys 创建的主题 程序员 有个词,是讲程序的抗异常能力
韧性
2021-05-10 23:36:06 +08:00
回复了 zhongpingjing 创建的主题 Java 假如 CPU 只有一个核心,使用 CAS 并发竞争的问题
N.B. You most likely do _not_ want to use MicroSpinLock or any
* other kind of spinlock. Consider MicroLock instead.”

你连英语都不懂吗。。。
2021-05-09 02:00:57 +08:00
回复了 zhongpingjing 创建的主题 Java 假如 CPU 只有一个核心,使用 CAS 并发竞争的问题
@fengjianxinghun 在进入睡眠之前自旋一会尝试去获取锁那是因为有时候锁短时间内就能获取到,不必要走 slowpath,多了上下文切换等资源损耗。

这就是我说的"除非你真的知道你在做什么"的场景。
spinlock 没有问题,有问题用错场景的人。这里不是解决 spinlock 的问题,这里解决的是 muted lock 在发生竞争时 overhead 过多的问题。


你没必要再拿这种打自己脸的例子来解释了,用户态锁场景下 99%都不应该用 spinlock,就是事实。
说什么你用了 mutex 就是用了 spinlock 简直是偷换概念,胡搅蛮缠。



重要的事情说三遍:

N.B. You most likely do _not_ want to use MicroSpinLock or any
* other kind of spinlock. Consider MicroLock instead.”


N.B. You most likely do _not_ want to use MicroSpinLock or any
* other kind of spinlock. Consider MicroLock instead.”


N.B. You most likely do _not_ want to use MicroSpinLock or any
* other kind of spinlock. Consider MicroLock instead.”
2021-05-09 01:42:43 +08:00
回复了 zhongpingjing 创建的主题 Java 假如 CPU 只有一个核心,使用 CAS 并发竞争的问题
@fengjianxinghun 你再仔细看看我说的话,和你说的话,确保你理解我的意思吧。
2021-05-07 22:11:39 +08:00
回复了 zhongpingjing 创建的主题 Java 假如 CPU 只有一个核心,使用 CAS 并发竞争的问题
@fengjianxinghun 你发的链接恰好证明 Linus 是对的。
你难道没发现,你所发的代码,都特别注明,大部分情况下不要使用自旋锁吗?
在能够抢占或者中断的操作系统里,用户态自旋锁在很多情况下都毫无意义(只会浪费 CPU 时间)

“/*
* N.B. You most likely do _not_ want to use MicroSpinLock or any
* other kind of spinlock. Consider MicroLock instead.”
2021-05-03 22:14:09 +08:00
回复了 zhongpingjing 创建的主题 Java 假如 CPU 只有一个核心,使用 CAS 并发竞争的问题
>cpu 只有一个核心,A 线程占用了 CPU,B 应该不能自旋了吧??
是的,A 线程占用了 CPU,B 线程的代码无法执行

>是不是只能等 A 执行完毕
不是的。即使 A 线程占用了 CPU,那也不意味着你能一直占着直到你的任务结束。
有因素会打算 A,然后切换到 B 。比如分给 A 任务的时间消耗完了,A 被调度出去;
比如中断和抢占打断了。


另外,不要用户态使用自旋锁,非常非常地愚蠢,除非你真的清楚自己在做什么。
引用 Linus 的话:
>I repeat: do not use spinlocks in user space, unless you actually know what you're doing. And be aware that the likelihood that you know what you are doing is basically nil.
2021-03-06 12:08:02 +08:00
回复了 xarthur 创建的主题 Vim 2021 年 Vim 的自动补全和 Debug
coc good!
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5385 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 06:48 · PVG 14:48 · LAX 23:48 · JFK 02:48
Developed with CodeLauncher
♥ Do have faith in what you're doing.