TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

C11 atomic variables and the Linux kernel (2014)

120 点作者 Rovanion超过 9 年前

3 条评论

rayiner超过 9 年前
The really interesting part is the discussion of optimizations:<p>&gt; Consider this example raised by Linus: the compiler might look at how the kernel accesses page table entries and notice that no code ever sets the &quot;page dirty&quot; bit. It might then conclude that any tests against that bit could simply be optimized out. But that bit can change; it&#x27;s just that the hardware makes the change, not the kernel code. So any optimizations made based on the notion that the compiler can &quot;prove&quot; that bit will never be set will lead to bad things. Linus concluded: &quot;Any optimization that tries to prove anything from more than local state is by definition broken, because it assumes that everything is described by the program.&quot;<p>Programmers tend to assume that optimization is transparent--code will work the same regardless. But that&#x27;s not really true, and as Linus&#x27;s example demonstrates, compiler writers and compiler users may have different ideas of what the compiler is allowed to assume. And there isn&#x27;t an obvious line to be drawn regarding safe and unsafe assumptions either.
rwmj超过 9 年前
I think the lesson is - if you&#x27;re going to write a kernel, you also need to write your own compiler, and that leads you to writing your own language too.
评论 #10620210 未加载
评论 #10620331 未加载
mojuba超过 9 年前
It&#x27;s funny how C and C++ standard names are not Y2K compliant. Are the committees so confident the languages won&#x27;t be around in 80-100 years from now? :) I wouldn&#x27;t be so sure.
评论 #10620377 未加载
评论 #10620314 未加载