This is the mail archive of the
mailing list for the pthreas-win32 project.
A question about thread cancellation
- From: "Fu Limin" <limin dot fu at ircc dot it>
- To: pthreads-win32 at sources dot redhat dot com
- Date: Thu, 29 Sep 2005 18:12:59 +0200 (CEST)
- Subject: A question about thread cancellation
- Reply-to: limin dot fu at ircc dot it
I have a question on thread cancellation, which is not specifically
relevant to pthread-win32, I hope you will not mind if I post it in this
In my program, there is a global mutex and a condition variable. And there
are several threads wait on this cond.var. under the protection of this
mutex. When I cancel one of the threads, I found there is a trouble in the
thread clean up. Because the mutex can be in either locked or unlocked
state. And if it is in locked state, I can't tell if it is locked by
another thread, or it gets the locked state from the cancellation point
pthread_cond_wait()! If it is locked by another thread, I should do
nothing on it, but if it gets the locked state by returning from
pthread_cond_wait() due to cancellation, I should unlock it in the clean
So the problem is, how can I know, in the clean up, when should I unlock
the mutex, and when not? Did any body have experienced similar problem?
Does anybody have any hints on this?
Thanks a lot!!!