NPTL SIGCONT和线程调度 [英] nptl SIGCONT and thread scheduling

查看:131
本文介绍了NPTL SIGCONT和线程调度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图端口code依靠SIGCONT停止的应用程序的某些线程。随着目前Linux NPTL的实现似乎2.6.x内核人们不能依靠这一点。我试图设计一种方法来阻止其他线程。目前,我只能认为对互斥和条件变量。任何提示的AP preciated。

I'm trying to port a code that relies on SIGCONT to stop certain threads of an application. With current linux nptl implementation seems one can't rely on that in 2.6.x kernels. I'm trying to devise a method to stop other threads. Currently I can only think on mutexes and condition variables. Any hints is appreciated.

推荐答案

如果你是靠停止和恢复其他线程,那么你的应用程序最终将失败。

If you are relying on stopping and resuming other threads, then your application will eventually fail.

这是因为,你不能保证你不会停止一个线程,而它已经采取了互斥可保护共享的资源。这将导致死锁,因为任何其他线程(可能包括其停止第一个线程的),然后需要等待互斥,将永远等待。

That is because, you cannot guarantee that you're not going to stop a thread while it has a mutex taken which protects a shared resource. This would result in deadlock, as any other threads (possibly including the one which stopped the first thread) which then need to wait for the mutex, will wait forever.

我相信这是可能的,而且,你这样做是错误的。

I'm sure it is possible, but also, you're doing it wrong.

注:如互斥体可能存在于C库的一部分,即使你有没有在自己的code。如果你在自己的code则没有,这是平凡的,我会感到惊讶。

NB: such mutexes probably exist in parts of the C library, even if you have none in your own code. If you have none in your own code and it is nontrivial, I'd be surprised.

这篇关于NPTL SIGCONT和线程调度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆