在用户空间使用futex?
我需要在锁定/解锁上下文之外的用户空间中调用 do_futex() 的功能。即,我不需要互斥锁,而是内核调用 do_futex 的确切语义。
它似乎应该在用户空间中可用,因为目的是最大限度地减少系统调用的数量,但我无法链接它。
或者有系统调用吗?
更新:
我目前正在使用 syscall(__NR_futex, ...) 来运行 do_futex()。但
- 我必须包含才能获得 __NR_futex,这很丑陋
- 我必须包含才能获得 FUTEX_WAIT 和 FUTEX_WAKE,但我仍然没有获得 EWOULDBLOCK,或者 WAKE 的最大线程数
是否有一个连贯的包装器?
I need functionality of do_futex() call in user space outside of lock/unlock context. I.e., I do not need a mutex, but the exact semantics of the kernel call do_futex.
It would seem it should be available in user space, since the intent was to minimize the number of system calls, but I can't link with it.
Or is there a syscall?
Update:
I'm currently using syscall(__NR_futex, ...) to run do_futex(). But
- I have to include to get __NR_futex, which is ugly
- I have to include to get FUTEX_WAIT and FUTEX_WAKE, but I still don't get EWOULDBLOCK, or the maximum number of threads for WAKE
Is there a coherent wrapper?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 http://locklessinc.com/articles/obscure_synch/ 上所说:
他们定义了自己的简单包装器:
As it's said on http://locklessinc.com/articles/obscure_synch/:
And they define their own simple wrapper:
futex(2) 系统调用可能就是您正在寻找的。
man 2 futex
另外,顺便说一下,man syscalls 给出了所有系统调用的列表。
futex(2) system call is probably what you are looking for.
man 2 futex
Also, on side note, man syscalls gives list of all system calls.