替换 Linux 2.6 中的系统调用(syscalls)

发布于 2024-11-16 03:04:49 字数 633 浏览 4 评论 0原文

我正在考虑编写一个 用户态线程库< /a>,因为该领域似乎没有积极的工作,并且我相信 C++0x 承诺和未来可能会给这个模型一些力量。不幸的是,为了使这个模型发挥作用,必须确保阻塞调用时的上下文切换。因此,我想拦截每个系统调用,以便用异步版本替换它。有一些警告:

  • 我知道几乎每个常规系统调用都有异步系统调用,但出于向后兼容性的原因,这不是一个可行的解决方案。
  • 我知道在 Linux 2.4 或更早版本中可以直接更改 sys_call_table,但这已经消失了。
  • 由于我希望我的库能够在需要时静态链接,因此 LD_PRELOAD 技巧不可行。
  • 同样,内核模块也不是一个选项,因为它应该是一个用户态库。
  • 最后,出于类似的原因,ptrace() 也不是一个选项。我不能让我的库仅仅为了使用而分叉一个新进程。

这可能吗?

I'm looking into writing a userland threading library, since there seems to be no active work in this area, and I believe the C++0x promises and futures may give this model some power. Unfortunately, in order to make this model work, it is essential to ensure a context switch on blocking calls. As such, I would like to intercept every syscall in order to replace it with an asynchronous version. There are some caveats:

  • I know there are asynchronous syscalls for just about every regular syscall, but for backwards compatibility reasons this is not a viable solution.
  • I know that in Linux 2.4 or earlier it was possible to directly change the sys_call_table, but this has vanished.
  • As I would like my library to be statically linked if desired, the LD_PRELOAD trick isn't viable.
  • Similarly, kernel modules are not an option because this is supposed to be a userland library.
  • Finally, ptrace() is also not an option for similar reasons. I can't have my library forking a new process just in order to be used.

Is this possible?

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

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

发布评论

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

评论(1

﹎☆浅夏丿初晴 2024-11-23 03:04:49

我正在考虑编写一个用户态线程库,因为该领域似乎没有活跃的工作

您可能想看看线程库 Marcel (及其 出版物)和MPC,它们实现了混合(内核 用户级)线程,主要是为了高性能计算的目的,因此他们必须找到一些解决方案来解决这种阻塞系统调用的问题。

从而避免应用程序时内核线程的阻塞
进行阻塞系统调用,Marcel 在以下情况下使用调度程序激活
它们是可用的,或者只是动态拦截此类阻塞调用
符号级别。

I'm looking into writing a userland threading library, since there seems to be no active work in this area

You might want to take a look at the thread libraries Marcel (and its publications) and MPC, which implement hybrid (kernel and user-level) threads, mainly in the purpose of High-Performance Computing, so they had to find some solution for this blocking system calls.

So as to avoid the blocking of kernel threads when the application
makes blocking system calls, Marcel uses Scheduler Activations when
they are available, or just intercepts such blocking calls at dynamic
symbols level.

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