如何查找pthread是否具有挂起的取消请求 [英] How to find whether a pthread has pending cancellation request

查看:88
本文介绍了如何查找pthread是否具有挂起的取消请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查找是否为一个线程调用了pthread_cancel.

I want to find whether for a thread, pthread_cancel has been called or not.

我不想使用某些表来维护它.有没有可用的库函数?我不想使用某些取消点函数来取消线程,如果有任何待处理的取消请求,它们会取消线程,我只是想知道是否有任何待处理的取消请求.

I don't want to use some tables and to maintain that. Is there any library function available for this? I don't want to cancel the thread using some cancellation point functions which cancel the thread if there is any pending cancellation request, I just want to know whether there is any pending cancellation request or not.

推荐答案

即使您调用pthread_cancel,它也不会立即执行.处理器花费自己的时间来取消线程.但是,仅在这里提到:不建议使用异步取消或立即取消.我在使用pthread_setcanceltype()作为PTHREAD_CANCEL_ASYNCHRONOUS时在取消过程中应用程序崩溃时遇到了一个问题.我真的找不到原因. 据我所知,甚至在调试崩溃情况时都进行了很多搜索,我们还没有一种方法可以确定线程在什么时候被取消.

Even if you call pthread_cancel, it is not executed immediately. Processor takes its own time to cancel the thread. But, just to mentioned here: usage of asynchronous cancellation or immediate cancellation is not recommended. I faced an issue where my application was crashing during cancellation when using the pthread_setcanceltype() as PTHREAD_CANCEL_ASYNCHRONOUS. I really could not find a reason why. As far as I know and even I have searched a lot for the same while debugging the crash scenario, we dont have a method to confirm at what point is the thread cancelled.

这篇关于如何查找pthread是否具有挂起的取消请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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