如何让我的同事相信 Linux 内核代码是可重入的?

发布于 2024-08-07 07:23:07 字数 567 浏览 5 评论 0原文

是的,我知道......有些人有时很难相信对我们其他人来说听起来很自然的事情,我现在需要你的帮助所以社区(或者我很快就会去邮寄..)

我的一位同事是他确信 Linux 内核代码是不可重入的,因为他上次对 Linux 内核代码感兴趣时(可能是 7 年前)在某个地方读过它。也许它的解读在当时是正确的,请记住,多核架构不久前还没有广泛普及,Linux 项目在其开始时左右并没有完全写得很好,也没有完全成熟,具有所有奇特的功能。

今天不同了。显然,从同一体系结构上并行运行的不同进程调用相同的系统调用不会导致未定义的行为。 Linux 内核现在很普遍,即使在多核架构上运行,也以其可靠性而闻名。 这就是我现在的论点。但你会用什么来客观地证明这一点呢?

我想向他展示 Linux 内核中的一些功能(在 lxr 网站 上)作为 mutex_lock()系统调用。一切都经过调整,使其能够在并发环境中工作。但对于新手(就像我一样)来说,代码可能并不那么明显。

请帮我.. ;-)

Yeah I know ... Some people are sometimes hard to convince of what sounds natural to the rest of us, an I need your help right now SO community (or I'll go postal soon ..)

One of my co-worker is convinced the linux kernel code is not re-entrant as he reads it somewhere last time he get insterested in it, likely 7 years ago. Probably its reading was right at that time, remember that multi core architecture was not much widespread some time ago and linux project at its begining or so was not totally well writen and fully fledged with all fancy features.

Today is different. It's obvious that calling the same system call from different processes running in parallel on the same architecture won't lead to undefined behavior. Linux kernel is widespread now, and known for its reability even though running on multicore architectures.
That is my argument for now. But what would be yours to prove that objectively ?

I was thinking to show him off some function in the linux kernel (on lxr website ) as the mutex_lock() system call. Eveything is tuned to get it work in concurrent environnement. But the code could be not that obvious for newbie (as I am).

Please help me.. ;-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

︶葆Ⅱㄣ 2024-08-14 07:23:08

在内核邮件列表存档中搜索“BKL”。它代表“大内核锁”,过去用于防止出现问题。我们已经投入了大量的工作来将其分解成多个部分,以便在不同进程使用内核的不同部分时允许重新进入。最近提到的“BKL”(至少我注意到)基本上指的是某人试图通过锁定比其他人认可的更多的东西来让自己的生活变得轻松,在这一点上他们经常说一些关于“回到过去的日子” BKL”,或者类似的东西。

Search the kernel mailing list archive for "BKL". That stands for "Big Kernel Lock", which is what used to be used to prevent problems. A lot of work has been put into breaking it up into pieces, to allow reentry as long different parts of the kernel are used by different processes. Most recent mentions of "BKL" (at least that I've noticed) have basically referred to somebody trying to make his own life easy by locking more than somebody else approved of, at which point they frequently say something about "returning to the days of the BKL", or something on that order.

凤舞天涯 2024-08-14 07:23:08

证明多个 CPU 可以同时在内核中执行的最简单方法是编写一个在内核中执行大量工作的程序(例如,在紧密循环中查找长路径名),然后在以下位置运行该程序的两个副本:同时在双核机器上进行测试,并显示 top 中的“系统”百分比超过 50%。

The easiest way to prove that multiple CPUs can execute in the kernel simultaneously would be to write a program that does a lot of work in-kernel (for example, looks up long pathnames in a tight loop), then run two copies of it at the same time on a dual-core machine and show that the "system" percentage in top goes above 50%.

夜巴黎 2024-08-14 07:23:08

冒着尖酸刻薄的风险:为什么不直接阅读代码呢?如果你们都不够专业,无法通过中断处理程序跟踪代码并进入某个子系统或另一个可以读出同步代码的子系统,那么......为什么还要麻烦呢?这不就是一场鸡毛蒜皮的争论吗?这就像一个神创论者在对学习任何生物学不感兴趣时​​却要求进化论的“证明”。

At the risk of being snarky: why not just read the code? If neither of you are expert enough to follow the code through an interrupt handler and into some subsystem or another where you can read out the synchronization code, then ... why bother? Isn't this just a dancing on the head of a pin argument? It's like a creationist demanding "proof" of evolution when they aren't interested in learning any biology.

终难遇 2024-08-14 07:23:08

也许您应该让您的朋友证明 Linux 是不可重入的。你不应该有责任证明这一点。

Maybe you should have your friend prove Linux is not reentrant. Burden should not be on you to prove this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文