[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multiple pthread_cancel() problem
From: |
Wolfram Gloger |
Subject: |
Re: multiple pthread_cancel() problem |
Date: |
10 Oct 2004 12:01:01 -0000 |
Hi,
> I am facing a problem in a multithread program where I send multiple
> pthread_cancels
> to a same thread from another thread.
Sounds like no "problem", but like misunderstanding.. You _cannot_
"send" multiple cancels!
> In the first thread Iam catching
> this
> pthread_cancel signal and returning to normal operation as if cancel
> signal has not come.
> This application works fine on Aix and Solaris but on Linux(redhat 9
> Kernel version 2.4.20-8)
> it is not working.
Thread cancellation is _not_ like a signal. It's semantics are rather
different. With LinuxThreads, cancellation is actually realized with
a signal _internally_, but that doesn't change the semantics.
> I would be greatful for your help and inputs in this regard.
>
> I could recreate this problem with native pthread calls and setjmp/longjmp
> calls. The
> following mail gives complete information about the problem.
>
> Here is the testcase to recreate the problem:
You omitted the testcase!
However, I suspect that when you do multiple pthread_cancel()s, the
thread is _gone_ on Linux by the time you perform the second
pthread_cancel() call. This is most probably how it should be.
> The pthread_clear_exit_np() function clears the exit status of the thread.
...
> This function is not portable
... and it is not available on Linux. (I'd like to add: _fortunately_
it is not available, as I absolutely cannot see a point in it)
> Is there any alternative(or any APIs available) here to make above
> testcase
> to run with expected o/p similar to AIX/SOLARIS. Can you pls let me know
> where
> Iam going wrong here.
Well, if you want signals, you know where to find them. Try
pthread_kill(). But note that it is really hard to mix signals and
threads correctly and usefully.
Regards,
Wolfram.