UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2009-10-13 09:10 AM

tomcio
Member
From: Poland
Registered: 2006-08-14
Posts: 113

Re: pthread and cancellation points

Hello!

I'm trying to do some more advanced things using threads and I don't exactly understand how cancellation points work. I read, that POSIX defines many function as cancellation points (accept(), select(), send() etc.) and also POSIX threads provides pthread_testcancel (). I don't exactly understand when exactly cancellation process is started for threads configured with PTHREAD_CANCEL_DEFERRED option.

One of cancellation points is send() function. Sample pseudocode executed inside thread:

while (1)
{
send ();
}

What happens when send() is sending some data and I cancel this thread from other place in program. send() execution is canceled immediately and thread exits or cancellation is deferred until next loop iteration?

Offline

#2 2010-07-20 08:35 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,234

Re: pthread and cancellation points

It's cancelled immediately, but if it's a send that doesn't block it might be fast
enough that the next one is cancelled instead.

Offline

Board footer

Powered by FluxBB