Re: (no subject)



I'm glad that your real problem was a simple one. However, this claim:

>> pthread_cancel() only has an effect when a thread encounters a
>> "cancellation point". for example, if it was executing:
>> 
>> 	      while (1);
>> 
>
>It will, in the real application. 

is, in general, false.

>What's pthread_cancel() for then? I'll have to read the man page more
>carefully.

pthread_cancel() will stop a thread that reaches a cancellation
point. a thread that never does so will never be cancelled. the loop
above never reaches a cancellation point. to cancel it would require a
pthreads implementation that cooperates with the kernel to make the
thread do something different when its rescheduled after its time
slice has expired. AFAIK, linuxthreads does not do this, and its
certainly not part of the P.1003 (Pthreads) specification.

the same problem would occur if you had a thread executing any code
that never calls any functions defined by POSIX to contain a
cancellation point. real life examples might include threads doing
intense math computation.

anyway, good luck with the rest of your code.

--p




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]