我可以将基于 futex 的互斥体与 glibc-2.2 linuxthreads 互斥体混合使用吗?
如果您不知道什么是 futex 和 linuxthreads-0.9,请不要回复。
我可以在一个程序中将基于 futex 的互斥体与来自 linuxthreads-0.8 或 -0.9 的互斥体(在所有 glibc <=2.2 和所有 uClibc 中使用)混合使用吗?
我需要进程间互斥体(pshared,PTHREAD_PROCESS_SHARED)。
那么,如果线程由linuxthreads pthread_manager启动和管理,是否会被基于futex的睡眠和唤醒所困惑?
我可以使用基于 futex 的互斥体进行进程间和线程间同步吗?
If you don't know what is futex and linuxthreads-0.9, please, don't reply.
Can I mix in one program futex-based mutex with mutex from linuxthreads-0.8 or -0.9 (which was used in all glibc <=2.2 and in all uClibc) ?
I need interprocess mutex (pshared one, PTHREAD_PROCESS_SHARED).
So, If threads are started and managed by linuxthreads pthread_manager, will it be confused by futex-based sleep and wake?
Can I use futex-based mutexes both for inter-process and inter-thread synchronization?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白你为什么不能。
显然,您将无法使用 pthread。您可能会使用带有旧互斥体的 pthread 库,并且需要在其他库中拥有 futex 代码。
显然,您无法锁定 linuxthreads 互斥体并使用 futex 函数解锁它,这永远不会起作用。
但是,如果一个线程在等待 futex 的内核中被阻塞,我看不出它与在磁盘 I/O 操作上被阻塞有什么不同,并且 linuxthreads 可以很好地处理这个问题。
I don't see why you couldn't.
You will not be able to use pthreads, obviously. You will probably be using the pthread library with the old mutexes and you will need to have the futex code in some other library.
You obviously cannot lock a linuxthreads mutex and unlock it with a futex function, that would never work.
But if one thread is blocked in the kernel waiting on a futex, I do not see how it's any different than being blocked on a disk I/O operation, and linuxthreads handles that well enough.