替换 Linux 2.6 中的系统调用(syscalls)
我正在考虑编写一个 用户态线程库< /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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想看看线程库 Marcel (及其 出版物)和MPC,它们实现了混合(内核和 用户级)线程,主要是为了高性能计算的目的,因此他们必须找到一些解决方案来解决这种阻塞系统调用的问题。
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.